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

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: '' 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 SpdyStream* stream = spdy_stream_;
67 spdy_stream_ = NULL;
68 return new SpdyHttpStream(stream);
69 }
70
62 // Sends a SYN_STREAM frame to the proxy with a CONNECT request 71 // Sends a SYN_STREAM frame to the proxy with a CONNECT request
63 // for the specified endpoint. Waits for the server to send back 72 // 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. 73 // 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. 74 // 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 75 // In any of these cases, Read() may be called to retrieve the HTTP
67 // response body. Any other return values should be considered fatal. 76 // response body. Any other return values should be considered fatal.
68 // TODO(rch): handle 407 proxy auth requested correctly, perhaps 77 // TODO(rch): handle 407 proxy auth requested correctly, perhaps
69 // by creating a new stream for the subsequent request. 78 // by creating a new stream for the subsequent request.
70 // TODO(rch): create a more appropriate error code to disambiguate 79 // TODO(rch): create a more appropriate error code to disambiguate
71 // the HTTPS Proxy tunnel failure from an HTTP Proxy tunnel failure. 80 // the HTTPS Proxy tunnel failure from an HTTP Proxy tunnel failure.
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 357
349 next_state_ = STATE_OPEN; 358 next_state_ = STATE_OPEN;
350 if (net_log_.IsLoggingAllEvents()) { 359 if (net_log_.IsLoggingAllEvents()) {
351 net_log_.AddEvent( 360 net_log_.AddEvent(
352 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, 361 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
353 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers))); 362 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers)));
354 } 363 }
355 364
356 if (response_.headers->response_code() == 200) 365 if (response_.headers->response_code() == 200)
357 return OK; 366 return OK;
367 else if (response_.headers->response_code() == 407)
368 return ERR_TUNNEL_CONNECTION_FAILED;
358 else 369 else
359 return ERR_TUNNEL_CONNECTION_FAILED; 370 return ERR_HTTPS_PROXY_TUNNEL_CONNECTION_RESPONSE;
360 } 371 }
361 372
362 // SpdyStream::Delegate methods: 373 // SpdyStream::Delegate methods:
363 // Called when SYN frame has been sent. 374 // Called when SYN frame has been sent.
364 // Returns true if no more data to be sent after SYN frame. 375 // Returns true if no more data to be sent after SYN frame.
365 bool SpdyProxyClientSocket::OnSendHeadersComplete(int status) { 376 bool SpdyProxyClientSocket::OnSendHeadersComplete(int status) {
366 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE); 377 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE);
367 378
368 OnIOComplete(status); 379 OnIOComplete(status);
369 380
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 read_callback->Run(status); 473 read_callback->Run(status);
463 } else if (read_callback_) { 474 } else if (read_callback_) {
464 // If we have a read_callback, the we need to make sure we call it back 475 // If we have a read_callback, the we need to make sure we call it back
465 OnDataReceived(NULL, 0); 476 OnDataReceived(NULL, 0);
466 } 477 }
467 if (write_callback) 478 if (write_callback)
468 write_callback->Run(ERR_CONNECTION_CLOSED); 479 write_callback->Run(ERR_CONNECTION_CLOSED);
469 } 480 }
470 481
471 } // namespace net 482 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698