OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/web_url_request_util.h" | 5 #include "content/child/web_url_request_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "net/base/load_flags.h" | 9 #include "net/base/load_flags.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 public: | 30 public: |
31 HeaderFlattener() : has_accept_header_(false) {} | 31 HeaderFlattener() : has_accept_header_(false) {} |
32 | 32 |
33 virtual void visitHeader(const WebString& name, const WebString& value) { | 33 virtual void visitHeader(const WebString& name, const WebString& value) { |
34 // Headers are latin1. | 34 // Headers are latin1. |
35 const std::string& name_latin1 = name.latin1(); | 35 const std::string& name_latin1 = name.latin1(); |
36 const std::string& value_latin1 = value.latin1(); | 36 const std::string& value_latin1 = value.latin1(); |
37 | 37 |
38 // Skip over referrer headers found in the header map because we already | 38 // Skip over referrer headers found in the header map because we already |
39 // pulled it out as a separate parameter. | 39 // pulled it out as a separate parameter. |
40 if (LowerCaseEqualsASCII(name_latin1, "referer")) | 40 if (base::LowerCaseEqualsASCII(name_latin1, "referer")) |
41 return; | 41 return; |
42 | 42 |
43 if (LowerCaseEqualsASCII(name_latin1, "accept")) | 43 if (base::LowerCaseEqualsASCII(name_latin1, "accept")) |
44 has_accept_header_ = true; | 44 has_accept_header_ = true; |
45 | 45 |
46 if (!buffer_.empty()) | 46 if (!buffer_.empty()) |
47 buffer_.append("\r\n"); | 47 buffer_.append("\r\n"); |
48 buffer_.append(name_latin1 + ": " + value_latin1); | 48 buffer_.append(name_latin1 + ": " + value_latin1); |
49 } | 49 } |
50 | 50 |
51 const std::string& GetBuffer() { | 51 const std::string& GetBuffer() { |
52 // In some cases, WebKit doesn't add an Accept header, but not having the | 52 // In some cases, WebKit doesn't add an Accept header, but not having the |
53 // header confuses some web servers. See bug 808613. | 53 // header confuses some web servers. See bug 808613. |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 error.localizedDescription = | 293 error.localizedDescription = |
294 WebString::fromUTF8(kThrottledErrorDescription); | 294 WebString::fromUTF8(kThrottledErrorDescription); |
295 } else { | 295 } else { |
296 error.localizedDescription = | 296 error.localizedDescription = |
297 WebString::fromUTF8(net::ErrorToString(reason)); | 297 WebString::fromUTF8(net::ErrorToString(reason)); |
298 } | 298 } |
299 return error; | 299 return error; |
300 } | 300 } |
301 | 301 |
302 } // namespace content | 302 } // namespace content |
OLD | NEW |