Commit 4467e580 authored by Douglas Creager's avatar Douglas Creager Committed by Commit Bot

Network Error Logging: Fill in protocol field

If ALPN protocol negotiation gives us an answer, use that directly;
otherwise, we assume HTTP/1.1 if any response headers were received.

Bug: 748549,833996
Change-Id: I33d6217ede6202358acf1a343296f5019a9b6052
Reviewed-on: https://chromium-review.googlesource.com/998021
Commit-Queue: Douglas Creager <dcreager@google.com>
Reviewed-by: default avatarJulia Tuttle <juliatuttle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551505}
parent 331dd506
......@@ -20,7 +20,6 @@
#include "net/base/net_errors.h"
#include "net/network_error_logging/network_error_logging_delegate.h"
#include "net/reporting/reporting_service.h"
#include "net/socket/next_proto.h"
#include "url/gurl.h"
#include "url/origin.h"
......@@ -474,10 +473,7 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService {
body->SetString(kReferrerKey, details.referrer.spec());
body->SetDouble(kSamplingFractionKey, sampling_fraction);
body->SetString(kServerIpKey, details.server_ip.ToString());
std::string protocol = NextProtoToString(details.protocol);
if (protocol == "unknown")
protocol = "";
body->SetString(kProtocolKey, protocol);
body->SetString(kProtocolKey, details.protocol);
body->SetInteger(kStatusCodeKey, details.status_code);
body->SetInteger(kElapsedTimeKey, details.elapsed_time.InMilliseconds());
body->SetString(kTypeKey, type);
......
......@@ -17,7 +17,6 @@
#include "net/base/ip_address.h"
#include "net/base/net_errors.h"
#include "net/base/net_export.h"
#include "net/socket/next_proto.h"
#include "url/gurl.h"
#include "url/origin.h"
......@@ -51,7 +50,7 @@ class NET_EXPORT NetworkErrorLoggingService {
GURL uri;
GURL referrer;
IPAddress server_ip;
NextProto protocol;
std::string protocol;
int status_code;
base::TimeDelta elapsed_time;
Error type;
......
......@@ -18,7 +18,6 @@
#include "net/network_error_logging/network_error_logging_service.h"
#include "net/reporting/reporting_policy.h"
#include "net/reporting/reporting_service.h"
#include "net/socket/next_proto.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"
......@@ -134,7 +133,6 @@ class NetworkErrorLoggingServiceTest : public ::testing::Test {
details.uri = url;
details.referrer = kReferrer_;
details.server_ip = IPAddress::IPv4AllZeros();
details.protocol = kProtoUnknown;
details.status_code = status_code;
details.elapsed_time = base::TimeDelta::FromSeconds(1);
details.type = error_type;
......
......@@ -1184,15 +1184,18 @@ void URLRequest::MaybeGenerateNetworkErrorLoggingReport() {
IPEndPoint endpoint;
if (GetRemoteEndpoint(&endpoint))
details.server_ip = endpoint.address();
// TODO(juliatuttle): Plumb this.
details.protocol = kProtoUnknown;
if (response_headers()) {
// HttpResponseHeaders::response_code() returns 0 if response code couldn't
// be parsed, which is also how NEL represents the same.
details.status_code = response_headers()->response_code();
// If we got response headers, assume that the connection used HTTP/1.1
// unless ALPN negotation tells us otherwise (handled below).
details.protocol = "http/1.1";
} else {
details.status_code = 0;
}
if (response_info().was_alpn_negotiated)
details.protocol = response_info().alpn_negotiated_protocol;
details.elapsed_time =
base::TimeTicks::Now() - load_timing_info_.request_start;
details.type = status().ToNetError();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment