| Index: net/tools/flip_server/spdy_interface.cc
|
| ===================================================================
|
| --- net/tools/flip_server/spdy_interface.cc (revision 122608)
|
| +++ net/tools/flip_server/spdy_interface.cc (working copy)
|
| @@ -145,33 +145,26 @@
|
| return sm_http_interface;
|
| }
|
|
|
| -int SpdySM::SpdyHandleNewStream(const SpdyControlFrame* frame,
|
| - std::string &http_data,
|
| - bool *is_https_scheme) {
|
| - bool parsed_headers = false;
|
| - SpdyHeaderBlock headers;
|
| - const SpdySynStreamControlFrame* syn_stream =
|
| - reinterpret_cast<const SpdySynStreamControlFrame*>(frame);
|
| -
|
| +int SpdySM::SpdyHandleNewStream(
|
| + const SpdySynStreamControlFrame* syn_stream,
|
| + const linked_ptr<spdy::SpdyHeaderBlock>& headers,
|
| + std::string &http_data,
|
| + bool* is_https_scheme) {
|
| *is_https_scheme = false;
|
| - parsed_headers = buffered_spdy_framer_->ParseHeaderBlock(frame, &headers);
|
| VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnSyn("
|
| << syn_stream->stream_id() << ")";
|
| - VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: headers parsed?: "
|
| - << (parsed_headers? "yes": "no");
|
| - if (parsed_headers) {
|
| - VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: # headers: "
|
| - << headers.size();
|
| - }
|
| - SpdyHeaderBlock::iterator url = headers.find("url");
|
| - SpdyHeaderBlock::iterator method = headers.find("method");
|
| - if (url == headers.end() || method == headers.end()) {
|
| + VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: # headers: "
|
| + << headers->size();
|
| +
|
| + SpdyHeaderBlock::iterator url = headers->find("url");
|
| + SpdyHeaderBlock::iterator method = headers->find("method");
|
| + if (url == headers->end() || method == headers->end()) {
|
| VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: didn't find method or url "
|
| << "or method. Not creating stream";
|
| return 0;
|
| }
|
|
|
| - SpdyHeaderBlock::iterator scheme = headers.find("scheme");
|
| + SpdyHeaderBlock::iterator scheme = headers->find("scheme");
|
| if (scheme->second.compare("https") == 0) {
|
| *is_https_scheme = true;
|
| }
|
| @@ -191,16 +184,15 @@
|
| << " " << uri;
|
| std::string filename = EncodeURL(uri, host, method->second);
|
| NewStream(syn_stream->stream_id(),
|
| - reinterpret_cast<const SpdySynStreamControlFrame*>
|
| - (frame)->priority(),
|
| + syn_stream->priority(),
|
| filename);
|
| } else {
|
| - SpdyHeaderBlock::iterator version = headers.find("version");
|
| + SpdyHeaderBlock::iterator version = headers->find("version");
|
| http_data += method->second + " " + uri + " " + version->second + "\r\n";
|
| VLOG(1) << ACCEPTOR_CLIENT_IDENT << "Request: " << method->second << " "
|
| << uri << " " << version->second;
|
| - for (SpdyHeaderBlock::iterator i = headers.begin();
|
| - i != headers.end(); ++i) {
|
| + for (SpdyHeaderBlock::iterator i = headers->begin();
|
| + i != headers->end(); ++i) {
|
| http_data += i->first + ": " + i->second + "\r\n";
|
| VLOG(2) << ACCEPTOR_CLIENT_IDENT << i->first.c_str() << ":"
|
| << i->second.c_str();
|
| @@ -217,81 +209,6 @@
|
| return 1;
|
| }
|
|
|
| -void SpdySM::OnControl(const SpdyControlFrame* frame) {
|
| - SpdyHeaderBlock headers;
|
| - bool parsed_headers = false;
|
| - switch (frame->type()) {
|
| - case SYN_STREAM:
|
| - {
|
| - const SpdySynStreamControlFrame* syn_stream =
|
| - reinterpret_cast<const SpdySynStreamControlFrame*>(frame);
|
| -
|
| - std::string http_data;
|
| - bool is_https_scheme;
|
| - int ret = SpdyHandleNewStream(frame, http_data, &is_https_scheme);
|
| - if (!ret) {
|
| - LOG(ERROR) << "SpdySM: Could not convert spdy into http.";
|
| - break;
|
| - }
|
| - // We've seen a valid looking SYN_STREAM, consider this to have
|
| - // been a real spdy session.
|
| - valid_spdy_session_ = true;
|
| -
|
| - if (acceptor_->flip_handler_type_ == FLIP_HANDLER_PROXY) {
|
| - std::string server_ip;
|
| - std::string server_port;
|
| - if (is_https_scheme) {
|
| - server_ip = acceptor_->https_server_ip_;
|
| - server_port = acceptor_->https_server_port_;
|
| - } else {
|
| - server_ip = acceptor_->http_server_ip_;
|
| - server_port = acceptor_->http_server_port_;
|
| - }
|
| - SMInterface *sm_http_interface =
|
| - FindOrMakeNewSMConnectionInterface(server_ip, server_port);
|
| - stream_to_smif_[syn_stream->stream_id()] = sm_http_interface;
|
| - sm_http_interface->SetStreamID(syn_stream->stream_id());
|
| - sm_http_interface->ProcessWriteInput(http_data.c_str(),
|
| - http_data.size());
|
| - }
|
| - }
|
| - break;
|
| -
|
| - case SYN_REPLY:
|
| - parsed_headers = buffered_spdy_framer_->ParseHeaderBlock(frame, &headers);
|
| - DCHECK(parsed_headers);
|
| - // TODO(willchan): if there is an error parsing headers, we
|
| - // should send a RST_STREAM.
|
| - VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnSynReply(" <<
|
| - reinterpret_cast<const SpdySynReplyControlFrame*>(frame)->stream_id()
|
| - << ")";
|
| - break;
|
| - case RST_STREAM:
|
| - {
|
| - const SpdyRstStreamControlFrame* rst_stream =
|
| - reinterpret_cast<const SpdyRstStreamControlFrame*>(frame);
|
| - VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnRst("
|
| - << rst_stream->stream_id() << ")";
|
| - client_output_ordering_.RemoveStreamId(rst_stream ->stream_id());
|
| - }
|
| - break;
|
| -
|
| - default:
|
| - LOG(ERROR) << "SpdySM: Unknown control frame type";
|
| - }
|
| -}
|
| -
|
| -bool SpdySM::OnControlFrameHeaderData(spdy::SpdyStreamId stream_id,
|
| - const char* header_data,
|
| - size_t len) {
|
| - DCHECK(false);
|
| - return false;
|
| -}
|
| -
|
| -void SpdySM::OnDataFrameHeader(const spdy::SpdyDataFrame* frame) {
|
| - buffered_spdy_framer_->OnDataFrameHeader(frame);
|
| -}
|
| -
|
| void SpdySM::OnStreamFrameData(SpdyStreamId stream_id,
|
| const char* data, size_t len) {
|
| VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: StreamData(" << stream_id
|
| @@ -309,23 +226,59 @@
|
| interface->ProcessWriteInput(data, len);
|
| }
|
|
|
| -bool SpdySM::OnCredentialFrameData(const char* frame_data,
|
| - size_t len) {
|
| - return false;
|
| -}
|
| +void SpdySM::OnSynStream(const spdy::SpdySynStreamControlFrame& syn_stream,
|
| + const linked_ptr<spdy::SpdyHeaderBlock>& headers) {
|
| + std::string http_data;
|
| + bool is_https_scheme;
|
| + int ret = SpdyHandleNewStream(&syn_stream, headers, http_data,
|
| + &is_https_scheme);
|
| + if (!ret) {
|
| + LOG(ERROR) << "SpdySM: Could not convert spdy into http.";
|
| + return;
|
| + }
|
| + // We've seen a valid looking SYN_STREAM, consider this to have
|
| + // been a real spdy session.
|
| + valid_spdy_session_ = true;
|
|
|
| -void SpdySM::OnSyn(const spdy::SpdySynStreamControlFrame& frame,
|
| - const linked_ptr<spdy::SpdyHeaderBlock>& headers) {
|
| + if (acceptor_->flip_handler_type_ == FLIP_HANDLER_PROXY) {
|
| + std::string server_ip;
|
| + std::string server_port;
|
| + if (is_https_scheme) {
|
| + server_ip = acceptor_->https_server_ip_;
|
| + server_port = acceptor_->https_server_port_;
|
| + } else {
|
| + server_ip = acceptor_->http_server_ip_;
|
| + server_port = acceptor_->http_server_port_;
|
| + }
|
| + SMInterface* sm_http_interface =
|
| + FindOrMakeNewSMConnectionInterface(server_ip, server_port);
|
| + stream_to_smif_[syn_stream.stream_id()] = sm_http_interface;
|
| + sm_http_interface->SetStreamID(syn_stream.stream_id());
|
| + sm_http_interface->ProcessWriteInput(http_data.c_str(),
|
| + http_data.size());
|
| + }
|
| }
|
|
|
| void SpdySM::OnSynReply(const spdy::SpdySynReplyControlFrame& frame,
|
| const linked_ptr<spdy::SpdyHeaderBlock>& headers) {
|
| + // TODO(willchan): if there is an error parsing headers, we
|
| + // should send a RST_STREAM.
|
| + VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnSynReply("
|
| + << frame.stream_id() << ")";
|
| }
|
|
|
| void SpdySM::OnHeaders(const spdy::SpdyHeadersControlFrame& frame,
|
| const linked_ptr<spdy::SpdyHeaderBlock>& headers) {
|
| + VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnHeaders("
|
| + << frame.stream_id() << ")";
|
| }
|
|
|
| +void SpdySM::OnRstStream(const spdy::SpdyRstStreamControlFrame& frame) {
|
| + VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnRstStream("
|
| + << frame.stream_id() << ")";
|
| + client_output_ordering_.RemoveStreamId(frame.stream_id());
|
| +}
|
| +
|
| size_t SpdySM::ProcessReadInput(const char* data, size_t len) {
|
| return buffered_spdy_framer_->ProcessInput(data, len);
|
| }
|
|
|