OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // Ensure that we do not send username and password fields in the referrer. | 187 // Ensure that we do not send username and password fields in the referrer. |
188 GURL referrer(request_->GetSanitizedReferrer()); | 188 GURL referrer(request_->GetSanitizedReferrer()); |
189 | 189 |
190 request_info_.url = request_->url(); | 190 request_info_.url = request_->url(); |
191 request_info_.referrer = referrer; | 191 request_info_.referrer = referrer; |
192 request_info_.method = request_->method(); | 192 request_info_.method = request_->method(); |
193 request_info_.load_flags = request_->load_flags(); | 193 request_info_.load_flags = request_->load_flags(); |
194 request_info_.priority = request_->priority(); | 194 request_info_.priority = request_->priority(); |
195 | 195 |
196 if (request_->context()) { | 196 if (request_->context()) { |
197 request_info_.extra_headers.SetHeader( | 197 request_info_.extra_headers.SetHeaderIfMissing( |
198 HttpRequestHeaders::kUserAgent, | 198 HttpRequestHeaders::kUserAgent, |
199 request_->context()->GetUserAgent(request_->url())); | 199 request_->context()->GetUserAgent(request_->url())); |
200 } | 200 } |
201 | 201 |
202 AddExtraHeaders(); | 202 AddExtraHeaders(); |
203 AddCookieHeaderAndStart(); | 203 AddCookieHeaderAndStart(); |
204 } | 204 } |
205 | 205 |
206 void URLRequestHttpJob::Kill() { | 206 void URLRequestHttpJob::Kill() { |
207 if (!transaction_.get()) | 207 if (!transaction_.get()) |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 // a response. When done, we'll record histograms via SDCH_DECODE or | 773 // a response. When done, we'll record histograms via SDCH_DECODE or |
774 // SDCH_PASSTHROUGH. Hence we need to record packet arrival times. | 774 // SDCH_PASSTHROUGH. Hence we need to record packet arrival times. |
775 EnablePacketCounting(kSdchPacketHistogramCount); | 775 EnablePacketCounting(kSdchPacketHistogramCount); |
776 } | 776 } |
777 } | 777 } |
778 | 778 |
779 URLRequestContext* context = request_->context(); | 779 URLRequestContext* context = request_->context(); |
780 if (context) { | 780 if (context) { |
781 // Only add default Accept-Language and Accept-Charset if the request | 781 // Only add default Accept-Language and Accept-Charset if the request |
782 // didn't have them specified. | 782 // didn't have them specified. |
783 if (!request_info_.extra_headers.HasHeader( | 783 request_info_.extra_headers.SetHeaderIfMissing( |
784 HttpRequestHeaders::kAcceptLanguage)) { | 784 HttpRequestHeaders::kAcceptLanguage, |
785 request_info_.extra_headers.SetHeader( | 785 context->accept_language()); |
786 HttpRequestHeaders::kAcceptLanguage, | 786 request_info_.extra_headers.SetHeaderIfMissing( |
787 context->accept_language()); | 787 HttpRequestHeaders::kAcceptCharset, |
788 } | 788 context->accept_charset()); |
789 if (!request_info_.extra_headers.HasHeader( | |
790 HttpRequestHeaders::kAcceptCharset)) { | |
791 request_info_.extra_headers.SetHeader( | |
792 HttpRequestHeaders::kAcceptCharset, | |
793 context->accept_charset()); | |
794 } | |
795 } | 789 } |
796 } | 790 } |
797 | 791 |
798 void URLRequestHttpJob::AddCookieHeaderAndStart() { | 792 void URLRequestHttpJob::AddCookieHeaderAndStart() { |
799 // No matter what, we want to report our status as IO pending since we will | 793 // No matter what, we want to report our status as IO pending since we will |
800 // be notifying our consumer asynchronously via OnStartCompleted. | 794 // be notifying our consumer asynchronously via OnStartCompleted. |
801 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); | 795 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); |
802 | 796 |
803 AddRef(); // Balanced in OnCanGetCookiesCompleted | 797 AddRef(); // Balanced in OnCanGetCookiesCompleted |
804 | 798 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 include_subdomains, | 954 include_subdomains, |
961 ctx->transport_security_state()); | 955 ctx->transport_security_state()); |
962 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), | 956 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), |
963 delegate)) { | 957 delegate)) { |
964 delete delegate; | 958 delete delegate; |
965 } | 959 } |
966 } | 960 } |
967 } | 961 } |
968 | 962 |
969 } // namespace net | 963 } // namespace net |
OLD | NEW |