OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 SpdyProxyClientSocket::~SpdyProxyClientSocket() { | 58 SpdyProxyClientSocket::~SpdyProxyClientSocket() { |
59 Disconnect(); | 59 Disconnect(); |
60 } | 60 } |
61 | 61 |
62 const HttpResponseInfo* SpdyProxyClientSocket::GetConnectResponseInfo() const { | 62 const HttpResponseInfo* SpdyProxyClientSocket::GetConnectResponseInfo() const { |
63 return response_.headers ? &response_ : NULL; | 63 return response_.headers ? &response_ : NULL; |
64 } | 64 } |
65 | 65 |
66 int SpdyProxyClientSocket::RestartWithAuth(OldCompletionCallback* callback) { | |
67 // A SPDY Stream can only handle a single request, so the underlying | |
68 // stream may not be reused and a new SpdyProxyClientSocket must be | |
69 // created (possibly on top of the same SPDY Session). | |
70 next_state_ = STATE_DISCONNECTED; | |
71 return OK; | |
72 } | |
73 | |
74 const | |
75 scoped_refptr<HttpAuthController>& SpdyProxyClientSocket::auth_controller() { | |
76 return auth_; | |
77 } | |
78 | |
79 HttpStream* SpdyProxyClientSocket::CreateConnectResponseStream() { | 66 HttpStream* SpdyProxyClientSocket::CreateConnectResponseStream() { |
80 DCHECK(response_stream_.get()); | 67 DCHECK(response_stream_.get()); |
81 return response_stream_.release(); | 68 return response_stream_.release(); |
82 } | 69 } |
83 | 70 |
84 // 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 |
85 // for the specified endpoint. Waits for the server to send back | 72 // for the specified endpoint. Waits for the server to send back |
86 // 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. |
87 // ERR_TUNNEL_CONNECTION_FAILED will be returned for any other status. | 74 // ERR_TUNNEL_CONNECTION_FAILED will be returned for any other status. |
88 // 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 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 next_state_ = STATE_OPEN; | 377 next_state_ = STATE_OPEN; |
391 if (net_log_.IsLoggingAllEvents()) { | 378 if (net_log_.IsLoggingAllEvents()) { |
392 net_log_.AddEvent( | 379 net_log_.AddEvent( |
393 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 380 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
394 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers))); | 381 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers))); |
395 } | 382 } |
396 | 383 |
397 if (response_.headers->response_code() == 200) { | 384 if (response_.headers->response_code() == 200) { |
398 return OK; | 385 return OK; |
399 } else if (response_.headers->response_code() == 407) { | 386 } else if (response_.headers->response_code() == 407) { |
400 int rv = HandleAuthChallenge(auth_, &response_, net_log_); | |
401 if (rv != ERR_PROXY_AUTH_REQUESTED) { | |
402 return rv; | |
403 } | |
404 // SPDY only supports basic and digest auth | |
405 if (auth_->auth_info() && | |
406 (auth_->auth_info()->scheme == "basic" || | |
407 auth_->auth_info()->scheme == "digest")) { | |
408 return ERR_PROXY_AUTH_REQUESTED; | |
409 } | |
410 return ERR_TUNNEL_CONNECTION_FAILED; | 387 return ERR_TUNNEL_CONNECTION_FAILED; |
411 } else { | 388 } else { |
412 // Immediately hand off our SpdyStream to a newly created SpdyHttpStream | 389 // Immediately hand off our SpdyStream to a newly created SpdyHttpStream |
413 // so that any subsequent SpdyFrames are processed in the context of | 390 // so that any subsequent SpdyFrames are processed in the context of |
414 // the HttpStream, not the socket. | 391 // the HttpStream, not the socket. |
415 DCHECK(spdy_stream_); | 392 DCHECK(spdy_stream_); |
416 SpdyStream* stream = spdy_stream_; | 393 SpdyStream* stream = spdy_stream_; |
417 spdy_stream_ = NULL; | 394 spdy_stream_ = NULL; |
418 response_stream_.reset(new SpdyHttpStream(NULL, false)); | 395 response_stream_.reset(new SpdyHttpStream(NULL, false)); |
419 response_stream_->InitializeWithExistingStream(stream); | 396 response_stream_->InitializeWithExistingStream(stream); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 OnDataReceived(NULL, 0); | 510 OnDataReceived(NULL, 0); |
534 } | 511 } |
535 if (write_callback) | 512 if (write_callback) |
536 write_callback->Run(ERR_CONNECTION_CLOSED); | 513 write_callback->Run(ERR_CONNECTION_CLOSED); |
537 } | 514 } |
538 | 515 |
539 void SpdyProxyClientSocket::set_chunk_callback(ChunkCallback* /*callback*/) { | 516 void SpdyProxyClientSocket::set_chunk_callback(ChunkCallback* /*callback*/) { |
540 } | 517 } |
541 | 518 |
542 } // namespace net | 519 } // namespace net |
OLD | NEW |