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

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

Issue 4935001: Allow a non-200 (or non-407) response for a CONNECT request from an HTTPS pro... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove stray reference to connect_response_http_stream.h Created 10 years 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
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_proxy_client_socket.h" 5 #include "net/spdy/spdy_proxy_client_socket.h"
6 6
7 #include <algorithm> // min 7 #include <algorithm> // min
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 request_.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, 52 request_.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
53 user_agent); 53 user_agent);
54 spdy_stream_->SetDelegate(this); 54 spdy_stream_->SetDelegate(this);
55 was_ever_used_ = spdy_stream_->WasEverUsed(); 55 was_ever_used_ = spdy_stream_->WasEverUsed();
56 } 56 }
57 57
58 SpdyProxyClientSocket::~SpdyProxyClientSocket() { 58 SpdyProxyClientSocket::~SpdyProxyClientSocket() {
59 Disconnect(); 59 Disconnect();
60 } 60 }
61 61
62 // In the event of a non-200 response to the CONNECT request, this
63 // method may be called to return an HttpStream in order to read
64 // the response body.
65 HttpStream* SpdyProxyClientSocket::GetConnectResponseStream() {
66 DCHECK(response_stream_.get());
67 return response_stream_.release();
68 }
69
62 // Sends a SYN_STREAM frame to the proxy with a CONNECT request 70 // Sends a SYN_STREAM frame to the proxy with a CONNECT request
63 // for the specified endpoint. Waits for the server to send back 71 // for the specified endpoint. Waits for the server to send back
64 // a SYN_REPLY frame. OK will be returned if the status is 200. 72 // a SYN_REPLY frame. OK will be returned if the status is 200.
65 // ERR_TUNNEL_CONNECTION_FAILED will be returned for any other status. 73 // ERR_TUNNEL_CONNECTION_FAILED will be returned for any other status.
66 // In any of these cases, Read() may be called to retrieve the HTTP 74 // In any of these cases, Read() may be called to retrieve the HTTP
67 // response body. Any other return values should be considered fatal. 75 // response body. Any other return values should be considered fatal.
68 // TODO(rch): handle 407 proxy auth requested correctly, perhaps 76 // TODO(rch): handle 407 proxy auth requested correctly, perhaps
69 // by creating a new stream for the subsequent request. 77 // by creating a new stream for the subsequent request.
70 // TODO(rch): create a more appropriate error code to disambiguate 78 // TODO(rch): create a more appropriate error code to disambiguate
71 // the HTTPS Proxy tunnel failure from an HTTP Proxy tunnel failure. 79 // the HTTPS Proxy tunnel failure from an HTTP Proxy tunnel failure.
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 if (response_.headers->GetParsedHttpVersion() < HttpVersion(1, 0)) 354 if (response_.headers->GetParsedHttpVersion() < HttpVersion(1, 0))
347 return ERR_TUNNEL_CONNECTION_FAILED; 355 return ERR_TUNNEL_CONNECTION_FAILED;
348 356
349 next_state_ = STATE_OPEN; 357 next_state_ = STATE_OPEN;
350 if (net_log_.IsLoggingAllEvents()) { 358 if (net_log_.IsLoggingAllEvents()) {
351 net_log_.AddEvent( 359 net_log_.AddEvent(
352 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, 360 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
353 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers))); 361 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers)));
354 } 362 }
355 363
356 if (response_.headers->response_code() == 200) 364 if (response_.headers->response_code() == 200) {
357 return OK; 365 return OK;
358 else 366 } else if (response_.headers->response_code() == 407) {
359 return ERR_TUNNEL_CONNECTION_FAILED; 367 return ERR_TUNNEL_CONNECTION_FAILED;
368 } else {
369 // Immediately hand off our SpdyStream to a newly created SpdyHttpStream
370 // so that any subsequent SpdyFrames are processed in the context of
371 // the HttpStream, not the socket.
372 DCHECK(spdy_stream_);
373 SpdyStream* stream = spdy_stream_;
374 spdy_stream_ = NULL;
375 response_stream_.reset(new SpdyHttpStream(stream));
376 return ERR_HTTPS_PROXY_TUNNEL_CONNECTION_RESPONSE;
377 }
360 } 378 }
361 379
362 // SpdyStream::Delegate methods: 380 // SpdyStream::Delegate methods:
363 // Called when SYN frame has been sent. 381 // Called when SYN frame has been sent.
364 // Returns true if no more data to be sent after SYN frame. 382 // Returns true if no more data to be sent after SYN frame.
365 bool SpdyProxyClientSocket::OnSendHeadersComplete(int status) { 383 bool SpdyProxyClientSocket::OnSendHeadersComplete(int status) {
366 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE); 384 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE);
367 385
368 OnIOComplete(status); 386 OnIOComplete(status);
369 387
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 read_callback->Run(status); 480 read_callback->Run(status);
463 } else if (read_callback_) { 481 } else if (read_callback_) {
464 // If we have a read_callback, the we need to make sure we call it back 482 // If we have a read_callback, the we need to make sure we call it back
465 OnDataReceived(NULL, 0); 483 OnDataReceived(NULL, 0);
466 } 484 }
467 if (write_callback) 485 if (write_callback)
468 write_callback->Run(ERR_CONNECTION_CLOSED); 486 write_callback->Run(ERR_CONNECTION_CLOSED);
469 } 487 }
470 488
471 } // namespace net 489 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698