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

Side by Side Diff: net/tools/flip_server/spdy_interface.cc

Issue 141953004: SPDY cleanup: remove credential slot. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixups to get flip_in_mem_edsm_server_unittests building & passing. Created 6 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/tools/flip_server/spdy_interface.h ('k') | net/tools/flip_server/spdy_interface_test.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tools/flip_server/spdy_interface.h" 5 #include "net/tools/flip_server/spdy_interface.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "net/spdy/spdy_framer.h" 10 #include "net/spdy/spdy_framer.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 int SpdySM::SpdyHandleNewStream(SpdyStreamId stream_id, 124 int SpdySM::SpdyHandleNewStream(SpdyStreamId stream_id,
125 SpdyPriority priority, 125 SpdyPriority priority,
126 const SpdyHeaderBlock& headers, 126 const SpdyHeaderBlock& headers,
127 std::string& http_data, 127 std::string& http_data,
128 bool* is_https_scheme) { 128 bool* is_https_scheme) {
129 *is_https_scheme = false; 129 *is_https_scheme = false;
130 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnSyn(" << stream_id << ")"; 130 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnSyn(" << stream_id << ")";
131 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: # headers: " << headers.size(); 131 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: # headers: " << headers.size();
132 132
133 SpdyHeaderBlock supplement;
134 SpdyHeaderBlock::const_iterator method = headers.end(); 133 SpdyHeaderBlock::const_iterator method = headers.end();
135 SpdyHeaderBlock::const_iterator host = headers.end(); 134 SpdyHeaderBlock::const_iterator host = headers.end();
136 SpdyHeaderBlock::const_iterator path = headers.end(); 135 SpdyHeaderBlock::const_iterator path = headers.end();
137 SpdyHeaderBlock::const_iterator scheme = headers.end(); 136 SpdyHeaderBlock::const_iterator scheme = headers.end();
138 SpdyHeaderBlock::const_iterator version = headers.end(); 137 SpdyHeaderBlock::const_iterator version = headers.end();
139 SpdyHeaderBlock::const_iterator url = headers.end(); 138 SpdyHeaderBlock::const_iterator url = headers.end();
140 139
140 std::string path_string, host_string, version_string;
141
141 if (spdy_version() == SPDY2) { 142 if (spdy_version() == SPDY2) {
142 url = headers.find("url"); 143 url = headers.find("url");
143 method = headers.find("method"); 144 method = headers.find("method");
144 version = headers.find("version"); 145 version = headers.find("version");
145 scheme = headers.find("scheme"); 146 scheme = headers.find("scheme");
146 if (url == headers.end() || method == headers.end() || 147 if (url == headers.end() || method == headers.end() ||
147 version == headers.end() || scheme == headers.end()) { 148 version == headers.end() || scheme == headers.end()) {
148 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: A mandatory header is " 149 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: A mandatory header is "
149 << "missing. Not creating stream"; 150 << "missing. Not creating stream";
150 return 0; 151 return 0;
151 } 152 }
152 // url->second here only ever seems to contain just the path. When this 153 // url->second here only ever seems to contain just the path. When this
153 // path contains a query string with a http:// in one of its values, 154 // path contains a query string with a http:// in one of its values,
154 // UrlUtilities::GetUrlPath will fail and always return a / breaking 155 // UrlUtilities::GetUrlPath will fail and always return a / breaking
155 // the request. GetUrlPath assumes the absolute URL is being passed in. 156 // the request. GetUrlPath assumes the absolute URL is being passed in.
156 std::string path_string = UrlUtilities::GetUrlPath(url->second); 157 path_string = UrlUtilities::GetUrlPath(url->second);
157 std::string host_string = UrlUtilities::GetUrlHost(url->second); 158 host_string = UrlUtilities::GetUrlHost(url->second);
158 path = supplement.insert(std::make_pair(":path", path_string)).first; 159 version_string = version->second;
159 host = supplement.insert(std::make_pair(":host", host_string)).first;
160 } else { 160 } else {
161 method = headers.find(":method"); 161 method = headers.find(":method");
162 host = headers.find(":host"); 162 host = headers.find(":host");
163 path = headers.find(":path"); 163 path = headers.find(":path");
164 scheme = headers.find(":scheme"); 164 scheme = headers.find(":scheme");
165 version = supplement.insert(std::make_pair(":version", "HTTP/1.1")).first;
166 if (method == headers.end() || host == headers.end() || 165 if (method == headers.end() || host == headers.end() ||
167 path == headers.end() || scheme == headers.end()) { 166 path == headers.end() || scheme == headers.end()) {
168 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: A mandatory header is " 167 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: A mandatory header is "
169 << "missing. Not creating stream"; 168 << "missing. Not creating stream";
170 return 0; 169 return 0;
171 } 170 }
171 host_string = host->second;
172 path_string = path->second;
173 version_string = "HTTP/1.1";
172 } 174 }
173 175
174 if (scheme->second.compare("https") == 0) { 176 if (scheme->second.compare("https") == 0) {
175 *is_https_scheme = true; 177 *is_https_scheme = true;
176 } 178 }
177 179
178 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_SPDY_SERVER) { 180 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_SPDY_SERVER) {
179 VLOG(1) << ACCEPTOR_CLIENT_IDENT << "Request: " << method->second 181 VLOG(1) << ACCEPTOR_CLIENT_IDENT << "Request: " << method->second
180 << " " << path->second; 182 << " " << path->second;
181 std::string filename = EncodeURL(path->second, 183 std::string filename = EncodeURL(path_string,
182 host->second, 184 host_string,
183 method->second); 185 method->second);
184 NewStream(stream_id, priority, filename); 186 NewStream(stream_id, priority, filename);
185 } else { 187 } else {
186 http_data += 188 http_data +=
187 method->second + " " + path->second + " " + version->second + "\r\n"; 189 method->second + " " + path_string + " " + version_string + "\r\n";
188 VLOG(1) << ACCEPTOR_CLIENT_IDENT << "Request: " << method->second << " " 190 VLOG(1) << ACCEPTOR_CLIENT_IDENT << "Request: " << method->second << " "
189 << path->second << " " << version->second; 191 << path->second << " " << version_string;
yhirano 2014/01/27 02:13:07 path_string
190 http_data += "Host: " + (*is_https_scheme ? 192 http_data += "Host: " + (*is_https_scheme ?
191 acceptor_->https_server_ip_ : 193 acceptor_->https_server_ip_ :
192 acceptor_->http_server_ip_) + "\r\n"; 194 acceptor_->http_server_ip_) + "\r\n";
193 for (SpdyHeaderBlock::const_iterator i = headers.begin(); 195 for (SpdyHeaderBlock::const_iterator i = headers.begin();
194 i != headers.end(); ++i) { 196 i != headers.end(); ++i) {
195 if ((i->first.size() > 0 && i->first[0] == ':') || 197 if ((i->first.size() > 0 && i->first[0] == ':') ||
196 i->first == "host" || 198 i->first == "host" ||
197 i == method || 199 i == method ||
198 i == host || 200 i == host ||
199 i == path || 201 i == path ||
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 236 }
235 237
236 SMInterface* interface = it->second; 238 SMInterface* interface = it->second;
237 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_PROXY) 239 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_PROXY)
238 interface->ProcessWriteInput(data, len); 240 interface->ProcessWriteInput(data, len);
239 } 241 }
240 242
241 void SpdySM::OnSynStream(SpdyStreamId stream_id, 243 void SpdySM::OnSynStream(SpdyStreamId stream_id,
242 SpdyStreamId associated_stream_id, 244 SpdyStreamId associated_stream_id,
243 SpdyPriority priority, 245 SpdyPriority priority,
244 uint8 credential_slot,
245 bool fin, 246 bool fin,
246 bool unidirectional, 247 bool unidirectional,
247 const SpdyHeaderBlock& headers) { 248 const SpdyHeaderBlock& headers) {
248 std::string http_data; 249 std::string http_data;
249 bool is_https_scheme; 250 bool is_https_scheme;
250 int ret = SpdyHandleNewStream( 251 int ret = SpdyHandleNewStream(
251 stream_id, priority, headers, http_data, &is_https_scheme); 252 stream_id, priority, headers, http_data, &is_https_scheme);
252 if (!ret) { 253 if (!ret) {
253 LOG(ERROR) << "SpdySM: Could not convert spdy into http."; 254 LOG(ERROR) << "SpdySM: Could not convert spdy into http.";
254 return; 255 return;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } else { 464 } else {
464 block[":path"] = headers.request_uri().as_string(); 465 block[":path"] = headers.request_uri().as_string();
465 if (block.find("host") != block.end()) { 466 if (block.find("host") != block.end()) {
466 block[":host"] = headers.GetHeader("Host").as_string(); 467 block[":host"] = headers.GetHeader("Host").as_string();
467 block.erase("host"); 468 block.erase("host");
468 } 469 }
469 } 470 }
470 } 471 }
471 472
472 SpdyFrame* fsrcf = buffered_spdy_framer_->CreateSynStream( 473 SpdyFrame* fsrcf = buffered_spdy_framer_->CreateSynStream(
473 stream_id, 0, 0, 0, CONTROL_FLAG_NONE, &block); 474 stream_id, 0, 0, CONTROL_FLAG_NONE, &block);
474 size_t df_size = fsrcf->size(); 475 size_t df_size = fsrcf->size();
475 EnqueueDataFrame(new SpdyFrameDataFrame(fsrcf)); 476 EnqueueDataFrame(new SpdyFrameDataFrame(fsrcf));
476 477
477 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: Sending SynStreamheader " 478 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: Sending SynStreamheader "
478 << stream_id; 479 << stream_id;
479 return df_size; 480 return df_size;
480 } 481 }
481 482
482 size_t SpdySM::SendSynReplyImpl(uint32 stream_id, const BalsaHeaders& headers) { 483 size_t SpdySM::SendSynReplyImpl(uint32 stream_id, const BalsaHeaders& headers) {
483 SpdyHeaderBlock block; 484 SpdyHeaderBlock block;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 0, 602 0,
602 should_compress); 603 should_compress);
603 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: GetOutput SendDataFrame[" 604 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: GetOutput SendDataFrame["
604 << mci->stream_id << "]: " << num_to_write; 605 << mci->stream_id << "]: " << num_to_write;
605 mci->body_bytes_consumed += num_to_write; 606 mci->body_bytes_consumed += num_to_write;
606 mci->bytes_sent += num_to_write; 607 mci->bytes_sent += num_to_write;
607 } 608 }
608 } 609 }
609 610
610 } // namespace net 611 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/flip_server/spdy_interface.h ('k') | net/tools/flip_server/spdy_interface_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698