diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-10-24 11:30:15 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-10-30 12:56:19 +0000 |
commit | 6036726eb981b6c4b42047513b9d3f4ac865daac (patch) | |
tree | 673593e70678e7789766d1f732eb51f613a2703b /chromium/net/http/http_proxy_client_socket.cc | |
parent | 466052c4e7c052268fd931888cd58961da94c586 (diff) | |
download | qtwebengine-chromium-6036726eb981b6c4b42047513b9d3f4ac865daac.tar.gz |
BASELINE: Update Chromium to 70.0.3538.78
Change-Id: Ie634710bf039e26c1957f4ae45e101bd4c434ae7
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/net/http/http_proxy_client_socket.cc')
-rw-r--r-- | chromium/net/http/http_proxy_client_socket.cc | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/chromium/net/http/http_proxy_client_socket.cc b/chromium/net/http/http_proxy_client_socket.cc index ea74e07660f..e55a99d1165 100644 --- a/chromium/net/http/http_proxy_client_socket.cc +++ b/chromium/net/http/http_proxy_client_socket.cc @@ -27,6 +27,8 @@ namespace net { +const int HttpProxyClientSocket::kDrainBodyBufferSize; + HttpProxyClientSocket::HttpProxyClientSocket( std::unique_ptr<ClientSocketHandle> transport_socket, const std::string& user_agent, @@ -198,22 +200,26 @@ int HttpProxyClientSocket::Read(IOBuffer* buf, int buf_len, CompletionOnceCallback callback) { DCHECK(user_callback_.is_null()); - if (next_state_ != STATE_DONE) { - // We're trying to read the body of the response but we're still trying - // to establish an SSL tunnel through the proxy. We can't read these - // bytes when establishing a tunnel because they might be controlled by - // an active network attacker. We don't worry about this for HTTP - // because an active network attacker can already control HTTP sessions. - // We reach this case when the user cancels a 407 proxy auth prompt. - // See http://crbug.com/8473. - DCHECK_EQ(407, response_.headers->response_code()); - + if (!CheckDone()) return ERR_TUNNEL_CONNECTION_FAILED; - } return transport_->socket()->Read(buf, buf_len, std::move(callback)); } +int HttpProxyClientSocket::ReadIfReady(IOBuffer* buf, + int buf_len, + CompletionOnceCallback callback) { + DCHECK(user_callback_.is_null()); + if (!CheckDone()) + return ERR_TUNNEL_CONNECTION_FAILED; + + return transport_->socket()->ReadIfReady(buf, buf_len, std::move(callback)); +} + +int HttpProxyClientSocket::CancelReadIfReady() { + return transport_->socket()->CancelReadIfReady(); +} + int HttpProxyClientSocket::Write( IOBuffer* buf, int buf_len, @@ -259,7 +265,7 @@ int HttpProxyClientSocket::PrepareForAuthRestart() { // If the auth request had a body, need to drain it before reusing the socket. if (!http_stream_parser_->IsResponseBodyComplete()) { next_state_ = STATE_DRAIN_BODY; - drain_buf_ = new IOBuffer(kDrainBodyBufferSize); + drain_buf_ = base::MakeRefCounted<IOBuffer>(kDrainBodyBufferSize); return OK; } @@ -393,7 +399,7 @@ int HttpProxyClientSocket::DoSendRequest() { base::Unretained(&request_headers_), &request_line_)); } - parser_buf_ = new GrowableIOBuffer(); + parser_buf_ = base::MakeRefCounted<GrowableIOBuffer>(); http_stream_parser_.reset(new HttpStreamParser( transport_.get(), &request_, parser_buf_.get(), net_log_)); return http_stream_parser_->SendRequest(request_line_, request_headers_, @@ -497,6 +503,22 @@ int HttpProxyClientSocket::DoDrainBodyComplete(int result) { return DidDrainBodyForAuthRestart(); } +bool HttpProxyClientSocket::CheckDone() { + if (next_state_ != STATE_DONE) { + // We're trying to read the body of the response but we're still trying + // to establish an SSL tunnel through the proxy. We can't read these + // bytes when establishing a tunnel because they might be controlled by + // an active network attacker. We don't worry about this for HTTP + // because an active network attacker can already control HTTP sessions. + // We reach this case when the user cancels a 407 proxy auth prompt. + // See http://crbug.com/8473. + DCHECK_EQ(407, response_.headers->response_code()); + + return false; + } + return true; +} + //---------------------------------------------------------------- } // namespace net |