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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 6065008: Do not override User-Agent header added by WebCore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_request_headers_unittest.cc ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // a response. When done, we'll record histograms via SDCH_DECODE or 296 // a response. When done, we'll record histograms via SDCH_DECODE or
297 // SDCH_PASSTHROUGH. Hence we need to record packet arrival times. 297 // SDCH_PASSTHROUGH. Hence we need to record packet arrival times.
298 EnablePacketCounting(kSdchPacketHistogramCount); 298 EnablePacketCounting(kSdchPacketHistogramCount);
299 } 299 }
300 } 300 }
301 301
302 URLRequestContext* context = request_->context(); 302 URLRequestContext* context = request_->context();
303 if (context) { 303 if (context) {
304 // Only add default Accept-Language and Accept-Charset if the request 304 // Only add default Accept-Language and Accept-Charset if the request
305 // didn't have them specified. 305 // didn't have them specified.
306 if (!request_info_.extra_headers.HasHeader( 306 request_info_.extra_headers.SetHeaderIfMissing(
307 HttpRequestHeaders::kAcceptLanguage)) { 307 HttpRequestHeaders::kAcceptLanguage,
308 request_info_.extra_headers.SetHeader( 308 context->accept_language());
309 HttpRequestHeaders::kAcceptLanguage, 309 request_info_.extra_headers.SetHeaderIfMissing(
310 context->accept_language()); 310 HttpRequestHeaders::kAcceptCharset,
311 } 311 context->accept_charset());
312 if (!request_info_.extra_headers.HasHeader(
313 HttpRequestHeaders::kAcceptCharset)) {
314 request_info_.extra_headers.SetHeader(
315 HttpRequestHeaders::kAcceptCharset,
316 context->accept_charset());
317 }
318 } 312 }
319 } 313 }
320 314
321 void URLRequestHttpJob::AddCookieHeaderAndStart() { 315 void URLRequestHttpJob::AddCookieHeaderAndStart() {
322 // No matter what, we want to report our status as IO pending since we will 316 // No matter what, we want to report our status as IO pending since we will
323 // be notifying our consumer asynchronously via OnStartCompleted. 317 // be notifying our consumer asynchronously via OnStartCompleted.
324 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); 318 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
325 319
326 AddRef(); // Balanced in OnCanGetCookiesCompleted 320 AddRef(); // Balanced in OnCanGetCookiesCompleted
327 321
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 // Ensure that we do not send username and password fields in the referrer. 647 // Ensure that we do not send username and password fields in the referrer.
654 GURL referrer(request_->GetSanitizedReferrer()); 648 GURL referrer(request_->GetSanitizedReferrer());
655 649
656 request_info_.url = request_->url(); 650 request_info_.url = request_->url();
657 request_info_.referrer = referrer; 651 request_info_.referrer = referrer;
658 request_info_.method = request_->method(); 652 request_info_.method = request_->method();
659 request_info_.load_flags = request_->load_flags(); 653 request_info_.load_flags = request_->load_flags();
660 request_info_.priority = request_->priority(); 654 request_info_.priority = request_->priority();
661 655
662 if (request_->context()) { 656 if (request_->context()) {
663 request_info_.extra_headers.SetHeader( 657 request_info_.extra_headers.SetHeaderIfMissing(
664 HttpRequestHeaders::kUserAgent, 658 HttpRequestHeaders::kUserAgent,
665 request_->context()->GetUserAgent(request_->url())); 659 request_->context()->GetUserAgent(request_->url()));
666 } 660 }
667 661
668 AddExtraHeaders(); 662 AddExtraHeaders();
669 AddCookieHeaderAndStart(); 663 AddCookieHeaderAndStart();
670 } 664 }
671 665
672 void URLRequestHttpJob::Kill() { 666 void URLRequestHttpJob::Kill() {
673 if (!transaction_.get()) 667 if (!transaction_.get())
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 // At shutdown time, care is taken to be sure that we don't delete this 955 // At shutdown time, care is taken to be sure that we don't delete this
962 // globally useful instance "too soon," so this check is just defensive 956 // globally useful instance "too soon," so this check is just defensive
963 // coding to assure that IF the system is shutting down, we don't have any 957 // coding to assure that IF the system is shutting down, we don't have any
964 // problem if the manager was deleted ahead of time. 958 // problem if the manager was deleted ahead of time.
965 if (manager) // Defensive programming. 959 if (manager) // Defensive programming.
966 manager->FetchDictionary(request_info_.url, sdch_dictionary_url_); 960 manager->FetchDictionary(request_info_.url, sdch_dictionary_url_);
967 } 961 }
968 } 962 }
969 963
970 } // namespace net 964 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_request_headers_unittest.cc ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698