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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 476
477 void URLRequestHttpJob::StartTransactionInternal() { 477 void URLRequestHttpJob::StartTransactionInternal() {
478 // This should only be called while the request's status is IO_PENDING. 478 // This should only be called while the request's status is IO_PENDING.
479 DCHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status()); 479 DCHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status());
480 480
481 // NOTE: This method assumes that request_info_ is already setup properly. 481 // NOTE: This method assumes that request_info_ is already setup properly.
482 482
483 // If we already have a transaction, then we should restart the transaction 483 // If we already have a transaction, then we should restart the transaction
484 // with auth provided by auth_credentials_. 484 // with auth provided by auth_credentials_.
485 485
486 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.
487 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.
488 it.GetNext();) {
489 if (!HttpUtil::IsValidHeaderValueRFC7230(it.value()))
490 ++invalid_header_values_in_RFC7230;
491 }
492 UMA_HISTOGRAM_BOOLEAN("Net.HttpRequestContainsInvalidHeaderValuesInRFC7230",
493 invalid_header_values_in_RFC7230 > 0);
494
486 int rv; 495 int rv;
487 496
488 if (network_delegate()) { 497 if (network_delegate()) {
489 network_delegate()->NotifySendHeaders( 498 network_delegate()->NotifySendHeaders(
490 request_, request_info_.extra_headers); 499 request_, request_info_.extra_headers);
491 } 500 }
492 501
493 if (transaction_.get()) { 502 if (transaction_.get()) {
494 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_); 503 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_);
495 auth_credentials_ = AuthCredentials(); 504 auth_credentials_ = AuthCredentials();
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 // If the job is done (due to cancellation), can just ignore this 927 // If the job is done (due to cancellation), can just ignore this
919 // notification. 928 // notification.
920 if (done_) 929 if (done_)
921 return; 930 return;
922 931
923 receive_headers_end_ = base::TimeTicks::Now(); 932 receive_headers_end_ = base::TimeTicks::Now();
924 933
925 // Clear the IO_PENDING status 934 // Clear the IO_PENDING status
926 SetStatus(URLRequestStatus()); 935 SetStatus(URLRequestStatus());
927 936
937 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.
938 void* iter = NULL;
939 std::string name;
940 std::string value;
941 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.
942 while (headers->EnumerateHeaderLines(&iter, &name, &value)) {
943 if (!HttpUtil::IsValidHeaderValueRFC7230(value))
944 ++invalid_header_values_in_RFC7230;
945 }
946 UMA_HISTOGRAM_BOOLEAN(
947 "Net.HttpResponseContainsInvalidHeaderValuesInRFC7230",
948 invalid_header_values_in_RFC7230 > 0);
949 }
950
928 const URLRequestContext* context = request_->context(); 951 const URLRequestContext* context = request_->context();
929 952
930 if (result == OK) { 953 if (result == OK) {
931 if (transaction_ && transaction_->GetResponseInfo()) { 954 if (transaction_ && transaction_->GetResponseInfo()) {
932 SetProxyServer(transaction_->GetResponseInfo()->proxy_server); 955 SetProxyServer(transaction_->GetResponseInfo()->proxy_server);
933 } 956 }
934 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); 957 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders();
935 if (network_delegate()) { 958 if (network_delegate()) {
936 // Note that |this| may not be deleted until 959 // Note that |this| may not be deleted until
937 // |on_headers_received_callback_| or 960 // |on_headers_received_callback_| or
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 return override_response_headers_.get() ? 1601 return override_response_headers_.get() ?
1579 override_response_headers_.get() : 1602 override_response_headers_.get() :
1580 transaction_->GetResponseInfo()->headers.get(); 1603 transaction_->GetResponseInfo()->headers.get();
1581 } 1604 }
1582 1605
1583 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1606 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1584 awaiting_callback_ = false; 1607 awaiting_callback_ = false;
1585 } 1608 }
1586 1609
1587 } // namespace net 1610 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698