| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 int SpdyProxyClientSocket::GetLocalAddress(IPEndPoint* address) const { | 259 int SpdyProxyClientSocket::GetLocalAddress(IPEndPoint* address) const { |
| 260 if (!IsConnected()) | 260 if (!IsConnected()) |
| 261 return ERR_SOCKET_NOT_CONNECTED; | 261 return ERR_SOCKET_NOT_CONNECTED; |
| 262 return spdy_stream_->GetLocalAddress(address); | 262 return spdy_stream_->GetLocalAddress(address); |
| 263 } | 263 } |
| 264 | 264 |
| 265 void SpdyProxyClientSocket::LogBlockedTunnelResponse() const { | 265 void SpdyProxyClientSocket::LogBlockedTunnelResponse() const { |
| 266 ProxyClientSocket::LogBlockedTunnelResponse( | 266 ProxyClientSocket::LogBlockedTunnelResponse( |
| 267 response_.headers->response_code(), | 267 response_.headers->response_code(), |
| 268 request_.url, | |
| 269 /* is_https_proxy = */ true); | 268 /* is_https_proxy = */ true); |
| 270 } | 269 } |
| 271 | 270 |
| 272 void SpdyProxyClientSocket::RunCallback(const CompletionCallback& callback, | 271 void SpdyProxyClientSocket::RunCallback(const CompletionCallback& callback, |
| 273 int result) const { | 272 int result) const { |
| 274 callback.Run(result); | 273 callback.Run(result); |
| 275 } | 274 } |
| 276 | 275 |
| 277 void SpdyProxyClientSocket::OnIOComplete(int result) { | 276 void SpdyProxyClientSocket::OnIOComplete(int result) { |
| 278 DCHECK_NE(STATE_DISCONNECTED, next_state_); | 277 DCHECK_NE(STATE_DISCONNECTED, next_state_); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 346 |
| 348 int SpdyProxyClientSocket::DoSendRequest() { | 347 int SpdyProxyClientSocket::DoSendRequest() { |
| 349 next_state_ = STATE_SEND_REQUEST_COMPLETE; | 348 next_state_ = STATE_SEND_REQUEST_COMPLETE; |
| 350 | 349 |
| 351 // Add Proxy-Authentication header if necessary. | 350 // Add Proxy-Authentication header if necessary. |
| 352 HttpRequestHeaders authorization_headers; | 351 HttpRequestHeaders authorization_headers; |
| 353 if (auth_->HaveAuth()) { | 352 if (auth_->HaveAuth()) { |
| 354 auth_->AddAuthorizationHeader(&authorization_headers); | 353 auth_->AddAuthorizationHeader(&authorization_headers); |
| 355 } | 354 } |
| 356 | 355 |
| 356 std::string user_agent; |
| 357 if (!request_.extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, |
| 358 &user_agent)) { |
| 359 user_agent.clear(); |
| 360 } |
| 357 std::string request_line; | 361 std::string request_line; |
| 358 HttpRequestHeaders request_headers; | 362 HttpRequestHeaders request_headers; |
| 359 BuildTunnelRequest(request_, authorization_headers, endpoint_, &request_line, | 363 BuildTunnelRequest(endpoint_, authorization_headers, user_agent, |
| 360 &request_headers); | 364 &request_line, &request_headers); |
| 361 | 365 |
| 362 net_log_.AddEvent( | 366 net_log_.AddEvent( |
| 363 NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 367 NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 364 base::Bind(&HttpRequestHeaders::NetLogCallback, | 368 base::Bind(&HttpRequestHeaders::NetLogCallback, |
| 365 base::Unretained(&request_headers), | 369 base::Unretained(&request_headers), |
| 366 &request_line)); | 370 &request_line)); |
| 367 | 371 |
| 368 request_.extra_headers.MergeFrom(request_headers); | 372 request_.extra_headers.MergeFrom(request_headers); |
| 369 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock()); | 373 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock()); |
| 370 CreateSpdyHeadersFromHttpRequest(request_, request_headers, | 374 CreateSpdyHeadersFromHttpRequest(request_, request_headers, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 } else if (!read_callback_.is_null()) { | 535 } else if (!read_callback_.is_null()) { |
| 532 // If we have a read_callback_, the we need to make sure we call it back. | 536 // If we have a read_callback_, the we need to make sure we call it back. |
| 533 OnDataReceived(scoped_ptr<SpdyBuffer>()); | 537 OnDataReceived(scoped_ptr<SpdyBuffer>()); |
| 534 } | 538 } |
| 535 // This may have been deleted by read_callback_, so check first. | 539 // This may have been deleted by read_callback_, so check first. |
| 536 if (weak_ptr.get() && !write_callback.is_null()) | 540 if (weak_ptr.get() && !write_callback.is_null()) |
| 537 write_callback.Run(ERR_CONNECTION_CLOSED); | 541 write_callback.Run(ERR_CONNECTION_CLOSED); |
| 538 } | 542 } |
| 539 | 543 |
| 540 } // namespace net | 544 } // namespace net |
| OLD | NEW |