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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 SpdyProxyClientSocket::~SpdyProxyClientSocket() { | 56 SpdyProxyClientSocket::~SpdyProxyClientSocket() { |
57 Disconnect(); | 57 Disconnect(); |
58 } | 58 } |
59 | 59 |
60 const HttpResponseInfo* SpdyProxyClientSocket::GetConnectResponseInfo() const { | 60 const HttpResponseInfo* SpdyProxyClientSocket::GetConnectResponseInfo() const { |
61 return response_.headers ? &response_ : NULL; | 61 return response_.headers ? &response_ : NULL; |
62 } | 62 } |
63 | 63 |
64 int SpdyProxyClientSocket::RestartWithAuth(OldCompletionCallback* callback) { | |
65 // A SPDY Stream can only handle a single request, so the underlying | |
66 // stream may not be reused and a new SpdyProxyClientSocket must be | |
67 // created (possibly on top of the same SPDY Session). | |
68 next_state_ = STATE_DISCONNECTED; | |
69 return OK; | |
70 } | |
71 | |
72 const | |
73 scoped_refptr<HttpAuthController>& SpdyProxyClientSocket::auth_controller() { | |
74 return auth_; | |
75 } | |
76 | |
77 HttpStream* SpdyProxyClientSocket::CreateConnectResponseStream() { | 64 HttpStream* SpdyProxyClientSocket::CreateConnectResponseStream() { |
78 DCHECK(response_stream_.get()); | 65 DCHECK(response_stream_.get()); |
79 return response_stream_.release(); | 66 return response_stream_.release(); |
80 } | 67 } |
81 | 68 |
82 // Sends a SYN_STREAM frame to the proxy with a CONNECT request | 69 // Sends a SYN_STREAM frame to the proxy with a CONNECT request |
83 // for the specified endpoint. Waits for the server to send back | 70 // for the specified endpoint. Waits for the server to send back |
84 // a SYN_REPLY frame. OK will be returned if the status is 200. | 71 // a SYN_REPLY frame. OK will be returned if the status is 200. |
85 // ERR_TUNNEL_CONNECTION_FAILED will be returned for any other status. | 72 // ERR_TUNNEL_CONNECTION_FAILED will be returned for any other status. |
86 // In any of these cases, Read() may be called to retrieve the HTTP | 73 // In any of these cases, Read() may be called to retrieve the HTTP |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 next_state_ = STATE_OPEN; | 369 next_state_ = STATE_OPEN; |
383 if (net_log_.IsLoggingAllEvents()) { | 370 if (net_log_.IsLoggingAllEvents()) { |
384 net_log_.AddEvent( | 371 net_log_.AddEvent( |
385 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 372 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
386 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers))); | 373 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers))); |
387 } | 374 } |
388 | 375 |
389 if (response_.headers->response_code() == 200) { | 376 if (response_.headers->response_code() == 200) { |
390 return OK; | 377 return OK; |
391 } else if (response_.headers->response_code() == 407) { | 378 } else if (response_.headers->response_code() == 407) { |
392 int rv = HandleAuthChallenge(auth_, &response_, net_log_); | |
393 if (rv != ERR_PROXY_AUTH_REQUESTED) { | |
394 return rv; | |
395 } | |
396 // SPDY only supports basic and digest auth | |
397 if (auth_->auth_info() && | |
398 (auth_->auth_info()->scheme == "basic" || | |
399 auth_->auth_info()->scheme == "digest")) { | |
400 return ERR_PROXY_AUTH_REQUESTED; | |
401 } | |
402 return ERR_TUNNEL_CONNECTION_FAILED; | 379 return ERR_TUNNEL_CONNECTION_FAILED; |
403 } else { | 380 } else { |
404 // Immediately hand off our SpdyStream to a newly created SpdyHttpStream | 381 // Immediately hand off our SpdyStream to a newly created SpdyHttpStream |
405 // so that any subsequent SpdyFrames are processed in the context of | 382 // so that any subsequent SpdyFrames are processed in the context of |
406 // the HttpStream, not the socket. | 383 // the HttpStream, not the socket. |
407 DCHECK(spdy_stream_); | 384 DCHECK(spdy_stream_); |
408 SpdyStream* stream = spdy_stream_; | 385 SpdyStream* stream = spdy_stream_; |
409 spdy_stream_ = NULL; | 386 spdy_stream_ = NULL; |
410 response_stream_.reset(new SpdyHttpStream(NULL, false)); | 387 response_stream_.reset(new SpdyHttpStream(NULL, false)); |
411 response_stream_->InitializeWithExistingStream(stream); | 388 response_stream_->InitializeWithExistingStream(stream); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 } | 504 } |
528 // This may have been deleted by read_callback_, so check first. | 505 // This may have been deleted by read_callback_, so check first. |
529 if (weak_ptr && !write_callback.is_null()) | 506 if (weak_ptr && !write_callback.is_null()) |
530 write_callback.Run(ERR_CONNECTION_CLOSED); | 507 write_callback.Run(ERR_CONNECTION_CLOSED); |
531 } | 508 } |
532 | 509 |
533 void SpdyProxyClientSocket::set_chunk_callback(ChunkCallback* /*callback*/) { | 510 void SpdyProxyClientSocket::set_chunk_callback(ChunkCallback* /*callback*/) { |
534 } | 511 } |
535 | 512 |
536 } // namespace net | 513 } // namespace net |
OLD | NEW |