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

Side by Side Diff: net/spdy/spdy_session.cc

Issue 1604011: Use HttpRequestHeaders for extra_headers. (Closed)
Patch Set: Address eroman comments. Created 10 years, 8 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
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/url_request/url_request_http_job.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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 response->headers = new HttpResponseHeaders(raw_headers); 126 response->headers = new HttpResponseHeaders(raw_headers);
127 response->was_fetched_via_spdy = true; 127 response->was_fetched_via_spdy = true;
128 return true; 128 return true;
129 } 129 }
130 130
131 // Create a SpdyHeaderBlock for a Spdy SYN_STREAM Frame from 131 // Create a SpdyHeaderBlock for a Spdy SYN_STREAM Frame from
132 // a HttpRequestInfo block. 132 // a HttpRequestInfo block.
133 void CreateSpdyHeadersFromHttpRequest( 133 void CreateSpdyHeadersFromHttpRequest(
134 const HttpRequestInfo& info, spdy::SpdyHeaderBlock* headers) { 134 const HttpRequestInfo& info, spdy::SpdyHeaderBlock* headers) {
135 // TODO(willchan): It's not really necessary to convert from
136 // HttpRequestHeaders to spdy::SpdyHeaderBlock.
137
135 static const char kHttpProtocolVersion[] = "HTTP/1.1"; 138 static const char kHttpProtocolVersion[] = "HTTP/1.1";
136 139
137 HttpUtil::HeadersIterator it(info.extra_headers.begin(), 140 HttpRequestHeaders::Iterator it(info.extra_headers);
138 info.extra_headers.end(), 141
139 "\r\n");
140 while (it.GetNext()) { 142 while (it.GetNext()) {
141 std::string name = StringToLowerASCII(it.name()); 143 std::string name = StringToLowerASCII(it.name());
142 if (headers->find(name) == headers->end()) { 144 if (headers->find(name) == headers->end()) {
143 (*headers)[name] = it.values(); 145 (*headers)[name] = it.value();
144 } else { 146 } else {
145 std::string new_value = (*headers)[name]; 147 std::string new_value = (*headers)[name];
146 new_value.append(1, '\0'); // +=() doesn't append 0's 148 new_value.append(1, '\0'); // +=() doesn't append 0's
147 new_value += it.values(); 149 new_value += it.value();
148 (*headers)[name] = new_value; 150 (*headers)[name] = new_value;
149 } 151 }
150 } 152 }
151 153
152 // TODO(mbelshe): Add Proxy headers here. (See http_network_transaction.cc) 154 // TODO(mbelshe): Add Proxy headers here. (See http_network_transaction.cc)
153 // TODO(mbelshe): Add authentication headers here. 155 // TODO(mbelshe): Add authentication headers here.
154 156
155 (*headers)["method"] = info.method; 157 (*headers)["method"] = info.method;
156 (*headers)["url"] = info.url.spec(); 158 (*headers)["url"] = info.url.spec();
157 (*headers)["version"] = kHttpProtocolVersion; 159 (*headers)["version"] = kHttpProtocolVersion;
158 if (info.user_agent.length())
159 (*headers)["user-agent"] = info.user_agent;
160 if (!info.referrer.is_empty()) 160 if (!info.referrer.is_empty())
161 (*headers)["referer"] = info.referrer.spec(); 161 (*headers)["referer"] = info.referrer.spec();
162 162
163 // Honor load flags that impact proxy caches. 163 // Honor load flags that impact proxy caches.
164 if (info.load_flags & LOAD_BYPASS_CACHE) { 164 if (info.load_flags & LOAD_BYPASS_CACHE) {
165 (*headers)["pragma"] = "no-cache"; 165 (*headers)["pragma"] = "no-cache";
166 (*headers)["cache-control"] = "no-cache"; 166 (*headers)["cache-control"] = "no-cache";
167 } else if (info.load_flags & LOAD_VALIDATE_CACHE) { 167 } else if (info.load_flags & LOAD_VALIDATE_CACHE) {
168 (*headers)["cache-control"] = "max-age=0"; 168 (*headers)["cache-control"] = "max-age=0";
169 } 169 }
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1092
1093 // TODO(willchan): Cancel any streams that are past the GoAway frame's 1093 // TODO(willchan): Cancel any streams that are past the GoAway frame's
1094 // |last_accepted_stream_id|. 1094 // |last_accepted_stream_id|.
1095 1095
1096 // Don't bother killing any streams that are still reading. They'll either 1096 // Don't bother killing any streams that are still reading. They'll either
1097 // complete successfully or get an ERR_CONNECTION_CLOSED when the socket is 1097 // complete successfully or get an ERR_CONNECTION_CLOSED when the socket is
1098 // closed. 1098 // closed.
1099 } 1099 }
1100 1100
1101 } // namespace net 1101 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698