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 | |
66 HttpStream* SpdyProxyClientSocket::CreateConnectResponseStream() { | 79 HttpStream* SpdyProxyClientSocket::CreateConnectResponseStream() { |
67 DCHECK(response_stream_.get()); | 80 DCHECK(response_stream_.get()); |
68 return response_stream_.release(); | 81 return response_stream_.release(); |
69 } | 82 } |
70 | 83 |
71 // Sends a SYN_STREAM frame to the proxy with a CONNECT request | 84 // Sends a SYN_STREAM frame to the proxy with a CONNECT request |
72 // for the specified endpoint. Waits for the server to send back | 85 // for the specified endpoint. Waits for the server to send back |
73 // a SYN_REPLY frame. OK will be returned if the status is 200. | 86 // a SYN_REPLY frame. OK will be returned if the status is 200. |
74 // ERR_TUNNEL_CONNECTION_FAILED will be returned for any other status. | 87 // ERR_TUNNEL_CONNECTION_FAILED will be returned for any other status. |
75 // In any of these cases, Read() may be called to retrieve the HTTP | 88 // 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... | |
377 next_state_ = STATE_OPEN; | 390 next_state_ = STATE_OPEN; |
378 if (net_log_.IsLoggingAllEvents()) { | 391 if (net_log_.IsLoggingAllEvents()) { |
379 net_log_.AddEvent( | 392 net_log_.AddEvent( |
380 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 393 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
381 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers))); | 394 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers))); |
382 } | 395 } |
383 | 396 |
384 if (response_.headers->response_code() == 200) { | 397 if (response_.headers->response_code() == 200) { |
385 return OK; | 398 return OK; |
386 } else if (response_.headers->response_code() == 407) { | 399 } 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 | |
cbentzel
2011/11/16 18:57:38
It looks like we don't expose the HttpAuthHandler
| |
405 if (auth_->auth_info() && | |
406 (auth_->auth_info()->scheme == "basic" || | |
407 auth_->auth_info()->scheme == "digest")) { | |
408 return ERR_PROXY_AUTH_REQUESTED; | |
409 } | |
387 return ERR_TUNNEL_CONNECTION_FAILED; | 410 return ERR_TUNNEL_CONNECTION_FAILED; |
388 } else { | 411 } else { |
389 // Immediately hand off our SpdyStream to a newly created SpdyHttpStream | 412 // Immediately hand off our SpdyStream to a newly created SpdyHttpStream |
390 // so that any subsequent SpdyFrames are processed in the context of | 413 // so that any subsequent SpdyFrames are processed in the context of |
391 // the HttpStream, not the socket. | 414 // the HttpStream, not the socket. |
392 DCHECK(spdy_stream_); | 415 DCHECK(spdy_stream_); |
393 SpdyStream* stream = spdy_stream_; | 416 SpdyStream* stream = spdy_stream_; |
394 spdy_stream_ = NULL; | 417 spdy_stream_ = NULL; |
395 response_stream_.reset(new SpdyHttpStream(NULL, false)); | 418 response_stream_.reset(new SpdyHttpStream(NULL, false)); |
396 response_stream_->InitializeWithExistingStream(stream); | 419 response_stream_->InitializeWithExistingStream(stream); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 OnDataReceived(NULL, 0); | 533 OnDataReceived(NULL, 0); |
511 } | 534 } |
512 if (write_callback) | 535 if (write_callback) |
513 write_callback->Run(ERR_CONNECTION_CLOSED); | 536 write_callback->Run(ERR_CONNECTION_CLOSED); |
514 } | 537 } |
515 | 538 |
516 void SpdyProxyClientSocket::set_chunk_callback(ChunkCallback* /*callback*/) { | 539 void SpdyProxyClientSocket::set_chunk_callback(ChunkCallback* /*callback*/) { |
517 } | 540 } |
518 | 541 |
519 } // namespace net | 542 } // namespace net |
OLD | NEW |