Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Unified Diff: net/url_request/url_request_http_job.cc

Issue 1374883002: Add UMAs for checking header values against RFC 7230 in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/url_request/url_request_http_job.cc
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 929d19467a6b5bb4ec4fb19aedcb4f0a77a355a0..3ad92fcbec0de886ac30c1902353035ccbc8e146 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -483,6 +483,15 @@ void URLRequestHttpJob::StartTransactionInternal() {
// If we already have a transaction, then we should restart the transaction
// with auth provided by auth_credentials_.
+ int invalid_header_values_in_RFC7230 = 0;
davidben 2015/12/15 21:16:36 This should probably be a bool (and then you can b
hiroshige 2015/12/17 06:36:02 Done.
+ for (net::HttpRequestHeaders::Iterator it(request_info_.extra_headers);
davidben 2015/12/15 21:16:36 Nit: No net:: prefix.
hiroshige 2015/12/17 06:36:02 Done.
+ it.GetNext();) {
+ if (!HttpUtil::IsValidHeaderValueRFC7230(it.value()))
+ ++invalid_header_values_in_RFC7230;
+ }
+ UMA_HISTOGRAM_BOOLEAN("Net.HttpRequestContainsInvalidHeaderValuesInRFC7230",
+ invalid_header_values_in_RFC7230 > 0);
+
int rv;
if (network_delegate()) {
@@ -925,6 +934,20 @@ void URLRequestHttpJob::OnStartCompleted(int result) {
// Clear the IO_PENDING status
SetStatus(URLRequestStatus());
+ if (scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders()) {
davidben 2015/12/15 21:16:36 I don't think we usually declare variables inside
hiroshige 2015/12/17 06:36:02 Done. Also I moved this to exclude error cases.
+ void* iter = NULL;
+ std::string name;
+ std::string value;
+ int invalid_header_values_in_RFC7230 = 0;
davidben 2015/12/15 21:16:36 Ditto about making this a bool.
hiroshige 2015/12/17 06:36:02 Done.
+ while (headers->EnumerateHeaderLines(&iter, &name, &value)) {
+ if (!HttpUtil::IsValidHeaderValueRFC7230(value))
+ ++invalid_header_values_in_RFC7230;
+ }
+ UMA_HISTOGRAM_BOOLEAN(
+ "Net.HttpResponseContainsInvalidHeaderValuesInRFC7230",
+ invalid_header_values_in_RFC7230 > 0);
+ }
+
const URLRequestContext* context = request_->context();
if (result == OK) {

Powered by Google App Engine
This is Rietveld 408576698