| OLD | NEW |
| 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 477 |
| 478 void URLRequestHttpJob::StartTransactionInternal() { | 478 void URLRequestHttpJob::StartTransactionInternal() { |
| 479 // This should only be called while the request's status is IO_PENDING. | 479 // This should only be called while the request's status is IO_PENDING. |
| 480 DCHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status()); | 480 DCHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status()); |
| 481 | 481 |
| 482 // NOTE: This method assumes that request_info_ is already setup properly. | 482 // NOTE: This method assumes that request_info_ is already setup properly. |
| 483 | 483 |
| 484 // If we already have a transaction, then we should restart the transaction | 484 // If we already have a transaction, then we should restart the transaction |
| 485 // with auth provided by auth_credentials_. | 485 // with auth provided by auth_credentials_. |
| 486 | 486 |
| 487 bool invalid_header_values_in_rfc7230 = false; |
| 488 for (HttpRequestHeaders::Iterator it(request_info_.extra_headers); |
| 489 it.GetNext();) { |
| 490 if (!HttpUtil::IsValidHeaderValueRFC7230(it.value())) { |
| 491 invalid_header_values_in_rfc7230 = true; |
| 492 break; |
| 493 } |
| 494 } |
| 495 UMA_HISTOGRAM_BOOLEAN("Net.HttpRequest.ContainsInvalidHeaderValuesInRFC7230", |
| 496 invalid_header_values_in_rfc7230); |
| 497 |
| 487 int rv; | 498 int rv; |
| 488 | 499 |
| 489 if (network_delegate()) { | 500 if (network_delegate()) { |
| 490 network_delegate()->NotifySendHeaders( | 501 network_delegate()->NotifySendHeaders( |
| 491 request_, request_info_.extra_headers); | 502 request_, request_info_.extra_headers); |
| 492 } | 503 } |
| 493 | 504 |
| 494 if (transaction_.get()) { | 505 if (transaction_.get()) { |
| 495 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_); | 506 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_); |
| 496 auth_credentials_ = AuthCredentials(); | 507 auth_credentials_ = AuthCredentials(); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 // Clear the IO_PENDING status | 932 // Clear the IO_PENDING status |
| 922 SetStatus(URLRequestStatus()); | 933 SetStatus(URLRequestStatus()); |
| 923 | 934 |
| 924 const URLRequestContext* context = request_->context(); | 935 const URLRequestContext* context = request_->context(); |
| 925 | 936 |
| 926 if (result == OK) { | 937 if (result == OK) { |
| 927 if (transaction_ && transaction_->GetResponseInfo()) { | 938 if (transaction_ && transaction_->GetResponseInfo()) { |
| 928 SetProxyServer(transaction_->GetResponseInfo()->proxy_server); | 939 SetProxyServer(transaction_->GetResponseInfo()->proxy_server); |
| 929 } | 940 } |
| 930 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); | 941 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); |
| 942 |
| 943 if (headers) { |
| 944 void* iter = NULL; |
| 945 std::string name; |
| 946 std::string value; |
| 947 bool invalid_header_values_in_rfc7230 = false; |
| 948 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { |
| 949 if (!HttpUtil::IsValidHeaderValueRFC7230(value)) { |
| 950 invalid_header_values_in_rfc7230 = true; |
| 951 break; |
| 952 } |
| 953 } |
| 954 UMA_HISTOGRAM_BOOLEAN( |
| 955 "Net.HttpResponse.ContainsInvalidHeaderValuesInRFC7230", |
| 956 invalid_header_values_in_rfc7230); |
| 957 } |
| 958 |
| 931 if (network_delegate()) { | 959 if (network_delegate()) { |
| 932 // Note that |this| may not be deleted until | 960 // Note that |this| may not be deleted until |
| 933 // |on_headers_received_callback_| or | 961 // |on_headers_received_callback_| or |
| 934 // |NetworkDelegate::URLRequestDestroyed()| has been called. | 962 // |NetworkDelegate::URLRequestDestroyed()| has been called. |
| 935 OnCallToDelegate(); | 963 OnCallToDelegate(); |
| 936 allowed_unsafe_redirect_url_ = GURL(); | 964 allowed_unsafe_redirect_url_ = GURL(); |
| 937 int error = network_delegate()->NotifyHeadersReceived( | 965 int error = network_delegate()->NotifyHeadersReceived( |
| 938 request_, | 966 request_, |
| 939 on_headers_received_callback_, | 967 on_headers_received_callback_, |
| 940 headers.get(), | 968 headers.get(), |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 return override_response_headers_.get() ? | 1603 return override_response_headers_.get() ? |
| 1576 override_response_headers_.get() : | 1604 override_response_headers_.get() : |
| 1577 transaction_->GetResponseInfo()->headers.get(); | 1605 transaction_->GetResponseInfo()->headers.get(); |
| 1578 } | 1606 } |
| 1579 | 1607 |
| 1580 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1608 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
| 1581 awaiting_callback_ = false; | 1609 awaiting_callback_ = false; |
| 1582 } | 1610 } |
| 1583 | 1611 |
| 1584 } // namespace net | 1612 } // namespace net |
| OLD | NEW |