 Chromium Code Reviews
 Chromium Code Reviews Issue 213010:
  Don't add default Accept-Language and Accept-Charset headers if specific ones were set in URLRequest  (Closed) 
  Base URL: svn://chrome-svn/chrome/trunk/src/
    
  
    Issue 213010:
  Don't add default Accept-Language and Accept-Charset headers if specific ones were set in URLRequest  (Closed) 
  Base URL: svn://chrome-svn/chrome/trunk/src/| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 636 // a response. When done, we'll record histograms via SDCH_DECODE or | 636 // a response. When done, we'll record histograms via SDCH_DECODE or | 
| 637 // SDCH_PASSTHROUGH. Hence we need to record packet arrival times. | 637 // SDCH_PASSTHROUGH. Hence we need to record packet arrival times. | 
| 638 EnablePacketCounting(kSdchPacketHistogramCount); | 638 EnablePacketCounting(kSdchPacketHistogramCount); | 
| 639 } | 639 } | 
| 640 } | 640 } | 
| 641 | 641 | 
| 642 URLRequestContext* context = request_->context(); | 642 URLRequestContext* context = request_->context(); | 
| 643 if (context) { | 643 if (context) { | 
| 644 if (context->AllowSendingCookies(request_)) | 644 if (context->AllowSendingCookies(request_)) | 
| 645 request_info_.extra_headers += AssembleRequestCookies(); | 645 request_info_.extra_headers += AssembleRequestCookies(); | 
| 646 if (!context->accept_language().empty()) | 646 | 
| 647 request_info_.extra_headers += "Accept-Language: " + | 647 // Only add default Accept-Language and Accept-Charset if the request | 
| 648 // didn't have them specifically specified. | |
| 649 static const std::string kAcceptLanguage = "Accept-Language"; | |
| 
eroman
2009/09/22 01:02:45
Can you make this a const char* instead?
 | |
| 650 if (!context->accept_language().empty() && | |
| 651 !net::HttpUtil::HasHeader(request_info_.extra_headers, kAcceptLanguage.c _str())) | |
| 
eroman
2009/09/22 01:02:45
break lines at 80 characters.
 | |
| 652 request_info_.extra_headers += kAcceptLanguage + ": " + | |
| 648 context->accept_language() + "\r\n"; | 653 context->accept_language() + "\r\n"; | 
| 649 if (!context->accept_charset().empty()) | 654 | 
| 650 request_info_.extra_headers += "Accept-Charset: " + | 655 static const std::string kAcceptCharset = "Accept-Charset"; | 
| 
eroman
2009/09/22 01:02:45
Please only use static const char*.
 | |
| 656 if (!context->accept_charset().empty() && | |
| 657 !net::HttpUtil::HasHeader(request_info_.extra_headers, kAcceptCharset.c_ str())) | |
| 
eroman
2009/09/22 01:02:45
break lines at 80 characters.
 | |
| 658 request_info_.extra_headers += kAcceptCharset + ": " + | |
| 
eroman
2009/09/22 01:02:45
Since this is the same as for accept-language, can
 | |
| 651 context->accept_charset() + "\r\n"; | 659 context->accept_charset() + "\r\n"; | 
| 652 } | 660 } | 
| 653 } | 661 } | 
| 654 | 662 | 
| 655 std::string URLRequestHttpJob::AssembleRequestCookies() { | 663 std::string URLRequestHttpJob::AssembleRequestCookies() { | 
| 656 if (request_info_.load_flags & net::LOAD_DO_NOT_SEND_COOKIES) | 664 if (request_info_.load_flags & net::LOAD_DO_NOT_SEND_COOKIES) | 
| 657 return std::string(); | 665 return std::string(); | 
| 658 | 666 | 
| 659 URLRequestContext* context = request_->context(); | 667 URLRequestContext* context = request_->context(); | 
| 660 if (context) { | 668 if (context) { | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 704 | 712 | 
| 705 std::string name = "Strict-Transport-Security"; | 713 std::string name = "Strict-Transport-Security"; | 
| 706 std::string value; | 714 std::string value; | 
| 707 | 715 | 
| 708 void* iter = NULL; | 716 void* iter = NULL; | 
| 709 while (response_info_->headers->EnumerateHeader(&iter, name, &value)) { | 717 while (response_info_->headers->EnumerateHeader(&iter, name, &value)) { | 
| 710 ctx->strict_transport_security_state()->DidReceiveHeader( | 718 ctx->strict_transport_security_state()->DidReceiveHeader( | 
| 711 request_info_.url, value); | 719 request_info_.url, value); | 
| 712 } | 720 } | 
| 713 } | 721 } | 
| OLD | NEW |