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/spdy/spdy_http_utils.h" | 5 #include "net/spdy/spdy_http_utils.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 | 77 |
78 void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info, | 78 void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info, |
79 const HttpRequestHeaders& request_headers, | 79 const HttpRequestHeaders& request_headers, |
80 spdy::SpdyHeaderBlock* headers, | 80 spdy::SpdyHeaderBlock* headers, |
81 bool direct) { | 81 bool direct) { |
82 | 82 |
83 HttpRequestHeaders::Iterator it(request_headers); | 83 HttpRequestHeaders::Iterator it(request_headers); |
84 while (it.GetNext()) { | 84 while (it.GetNext()) { |
85 std::string name = StringToLowerASCII(it.name()); | 85 std::string name = StringToLowerASCII(it.name()); |
86 if (name == "connection" || name == "proxy-connection") | 86 if (name == "connection" || name == "proxy-connection" || |
| 87 name == "transfer-encoding") { |
87 continue; | 88 continue; |
| 89 } |
88 if (headers->find(name) == headers->end()) { | 90 if (headers->find(name) == headers->end()) { |
89 (*headers)[name] = it.value(); | 91 (*headers)[name] = it.value(); |
90 } else { | 92 } else { |
91 std::string new_value = (*headers)[name]; | 93 std::string new_value = (*headers)[name]; |
92 new_value.append(1, '\0'); // +=() doesn't append 0's | 94 new_value.append(1, '\0'); // +=() doesn't append 0's |
93 new_value += it.value(); | 95 new_value += it.value(); |
94 (*headers)[name] = new_value; | 96 (*headers)[name] = new_value; |
95 } | 97 } |
96 } | 98 } |
97 static const char kHttpProtocolVersion[] = "HTTP/1.1"; | 99 static const char kHttpProtocolVersion[] = "HTTP/1.1"; |
98 | 100 |
99 (*headers)["version"] = kHttpProtocolVersion; | 101 (*headers)["version"] = kHttpProtocolVersion; |
100 (*headers)["method"] = info.method; | 102 (*headers)["method"] = info.method; |
101 (*headers)["host"] = GetHostAndOptionalPort(info.url); | 103 (*headers)["host"] = GetHostAndOptionalPort(info.url); |
102 (*headers)["scheme"] = info.url.scheme(); | 104 (*headers)["scheme"] = info.url.scheme(); |
103 if (direct) | 105 if (direct) |
104 (*headers)["url"] = HttpUtil::PathForRequest(info.url); | 106 (*headers)["url"] = HttpUtil::PathForRequest(info.url); |
105 else | 107 else |
106 (*headers)["url"] = HttpUtil::SpecForRequest(info.url); | 108 (*headers)["url"] = HttpUtil::SpecForRequest(info.url); |
107 | 109 |
108 } | 110 } |
109 | 111 |
110 } // namespace net | 112 } // namespace net |
OLD | NEW |