| Index: net/http/http_proxy_client_socket.cc
|
| diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc
|
| index 2f444284288447596174cb000f4129bbacc783f7..692a6e37c180a3cc9c1566ef32676db52dea095b 100644
|
| --- a/net/http/http_proxy_client_socket.cc
|
| +++ b/net/http/http_proxy_client_socket.cc
|
| @@ -62,6 +62,24 @@ HttpProxyClientSocket::~HttpProxyClientSocket() {
|
| Disconnect();
|
| }
|
|
|
| +int HttpProxyClientSocket::RestartWithAuth(CompletionCallback* callback) {
|
| + DCHECK_EQ(STATE_NONE, next_state_);
|
| + DCHECK(!user_callback_);
|
| +
|
| + int rv = PrepareForAuthRestart();
|
| + if (rv != OK)
|
| + return rv;
|
| +
|
| + rv = DoLoop(OK);
|
| + if (rv == ERR_IO_PENDING)
|
| + user_callback_ = callback;
|
| + return rv;
|
| +}
|
| +
|
| +const HttpResponseInfo* HttpProxyClientSocket::GetConnectResponseInfo() const {
|
| + return response_.headers ? &response_ : NULL;
|
| +}
|
| +
|
| HttpStream* HttpProxyClientSocket::CreateConnectResponseStream() {
|
| return new HttpBasicStream(transport_.release(),
|
| http_stream_parser_.release(), false);
|
| @@ -92,67 +110,6 @@ int HttpProxyClientSocket::Connect(CompletionCallback* callback) {
|
| return rv;
|
| }
|
|
|
| -int HttpProxyClientSocket::RestartWithAuth(CompletionCallback* callback) {
|
| - DCHECK_EQ(STATE_NONE, next_state_);
|
| - DCHECK(!user_callback_);
|
| -
|
| - int rv = PrepareForAuthRestart();
|
| - if (rv != OK)
|
| - return rv;
|
| -
|
| - rv = DoLoop(OK);
|
| - if (rv == ERR_IO_PENDING)
|
| - user_callback_ = callback;
|
| - return rv;
|
| -}
|
| -
|
| -int HttpProxyClientSocket::PrepareForAuthRestart() {
|
| - if (!response_.headers.get())
|
| - return ERR_CONNECTION_RESET;
|
| -
|
| - bool keep_alive = false;
|
| - if (response_.headers->IsKeepAlive() &&
|
| - http_stream_parser_->CanFindEndOfResponse()) {
|
| - if (!http_stream_parser_->IsResponseBodyComplete()) {
|
| - next_state_ = STATE_DRAIN_BODY;
|
| - drain_buf_ = new IOBuffer(kDrainBodyBufferSize);
|
| - return OK;
|
| - }
|
| - keep_alive = true;
|
| - }
|
| -
|
| - // We don't need to drain the response body, so we act as if we had drained
|
| - // the response body.
|
| - return DidDrainBodyForAuthRestart(keep_alive);
|
| -}
|
| -
|
| -int HttpProxyClientSocket::DidDrainBodyForAuthRestart(bool keep_alive) {
|
| - if (keep_alive && transport_->socket()->IsConnectedAndIdle()) {
|
| - next_state_ = STATE_GENERATE_AUTH_TOKEN;
|
| - transport_->set_is_reused(true);
|
| - } else {
|
| - // This assumes that the underlying transport socket is a TCP socket,
|
| - // since only TCP sockets are restartable.
|
| - next_state_ = STATE_TCP_RESTART;
|
| - transport_->socket()->Disconnect();
|
| - }
|
| -
|
| - // Reset the other member variables.
|
| - drain_buf_ = NULL;
|
| - parser_buf_ = NULL;
|
| - http_stream_parser_.reset();
|
| - request_line_.clear();
|
| - request_headers_.Clear();
|
| - response_ = HttpResponseInfo();
|
| - return OK;
|
| -}
|
| -
|
| -void HttpProxyClientSocket::LogBlockedTunnelResponse(int response_code) const {
|
| - LOG(WARNING) << "Blocked proxy response with status " << response_code
|
| - << " to CONNECT request for "
|
| - << GetHostAndPort(request_.url) << ".";
|
| -}
|
| -
|
| void HttpProxyClientSocket::Disconnect() {
|
| if (transport_.get())
|
| transport_->socket()->Disconnect();
|
| @@ -248,6 +205,64 @@ int HttpProxyClientSocket::GetPeerAddress(AddressList* address) const {
|
| return transport_->socket()->GetPeerAddress(address);
|
| }
|
|
|
| +int HttpProxyClientSocket::PrepareForAuthRestart() {
|
| + if (!response_.headers.get())
|
| + return ERR_CONNECTION_RESET;
|
| +
|
| + bool keep_alive = false;
|
| + if (response_.headers->IsKeepAlive() &&
|
| + http_stream_parser_->CanFindEndOfResponse()) {
|
| + if (!http_stream_parser_->IsResponseBodyComplete()) {
|
| + next_state_ = STATE_DRAIN_BODY;
|
| + drain_buf_ = new IOBuffer(kDrainBodyBufferSize);
|
| + return OK;
|
| + }
|
| + keep_alive = true;
|
| + }
|
| +
|
| + // We don't need to drain the response body, so we act as if we had drained
|
| + // the response body.
|
| + return DidDrainBodyForAuthRestart(keep_alive);
|
| +}
|
| +
|
| +int HttpProxyClientSocket::DidDrainBodyForAuthRestart(bool keep_alive) {
|
| + if (keep_alive && transport_->socket()->IsConnectedAndIdle()) {
|
| + next_state_ = STATE_GENERATE_AUTH_TOKEN;
|
| + transport_->set_is_reused(true);
|
| + } else {
|
| + // This assumes that the underlying transport socket is a TCP socket,
|
| + // since only TCP sockets are restartable.
|
| + next_state_ = STATE_TCP_RESTART;
|
| + transport_->socket()->Disconnect();
|
| + }
|
| +
|
| + // Reset the other member variables.
|
| + drain_buf_ = NULL;
|
| + parser_buf_ = NULL;
|
| + http_stream_parser_.reset();
|
| + request_line_.clear();
|
| + request_headers_.Clear();
|
| + response_ = HttpResponseInfo();
|
| + return OK;
|
| +}
|
| +
|
| +int HttpProxyClientSocket::HandleAuthChallenge() {
|
| + DCHECK(response_.headers);
|
| +
|
| + int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_);
|
| + response_.auth_challenge = auth_->auth_info();
|
| + if (rv == OK)
|
| + return ERR_PROXY_AUTH_REQUESTED;
|
| +
|
| + return rv;
|
| +}
|
| +
|
| +void HttpProxyClientSocket::LogBlockedTunnelResponse(int response_code) const {
|
| + LOG(WARNING) << "Blocked proxy response with status " << response_code
|
| + << " to CONNECT request for "
|
| + << GetHostAndPort(request_.url) << ".";
|
| +}
|
| +
|
| void HttpProxyClientSocket::DoCallback(int result) {
|
| DCHECK_NE(ERR_IO_PENDING, result);
|
| DCHECK(user_callback_);
|
| @@ -465,15 +480,4 @@ int HttpProxyClientSocket::DoTCPRestartComplete(int result) {
|
| return result;
|
| }
|
|
|
| -int HttpProxyClientSocket::HandleAuthChallenge() {
|
| - DCHECK(response_.headers);
|
| -
|
| - int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_);
|
| - response_.auth_challenge = auth_->auth_info();
|
| - if (rv == OK)
|
| - return ERR_PROXY_AUTH_REQUESTED;
|
| -
|
| - return rv;
|
| -}
|
| -
|
| } // namespace net
|
|
|