Chromium Code Reviews| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 // Ignore response to avoid letting the proxy impersonate the target | 423 // Ignore response to avoid letting the proxy impersonate the target |
| 424 // server. (See http://crbug.com/137891.) | 424 // server. (See http://crbug.com/137891.) |
| 425 LogBlockedTunnelResponse(); | 425 LogBlockedTunnelResponse(); |
| 426 return ERR_TUNNEL_CONNECTION_FAILED; | 426 return ERR_TUNNEL_CONNECTION_FAILED; |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 // SpdyStream::Delegate methods: | 430 // SpdyStream::Delegate methods: |
| 431 // Called when SYN frame has been sent. | 431 // Called when SYN frame has been sent. |
| 432 // Returns true if no more data to be sent after SYN frame. | 432 // Returns true if no more data to be sent after SYN frame. |
| 433 void SpdyProxyClientSocket::OnRequestHeadersSent() { | 433 void SpdyProxyClientSocket::OnHeadersSent() { |
| 434 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE); | 434 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE); |
| 435 | 435 |
| 436 OnIOComplete(OK); | 436 OnIOComplete(OK); |
| 437 } | 437 } |
| 438 | 438 |
| 439 SpdyResponseHeadersStatus SpdyProxyClientSocket::OnResponseHeadersUpdated( | 439 void SpdyProxyClientSocket::OnHeadersReceived( |
| 440 const SpdyHeaderBlock& response_headers) { | 440 const SpdyHeaderBlock& response_headers) { |
| 441 // If we've already received the reply, existing headers are too late. | 441 // If we've already received the reply, existing headers are too late. |
| 442 // TODO(mbelshe): figure out a way to make HEADERS frames useful after the | 442 // TODO(mbelshe): figure out a way to make HEADERS frames useful after the |
| 443 // initial response. | 443 // initial response. |
| 444 if (next_state_ != STATE_READ_REPLY_COMPLETE) | 444 if (next_state_ != STATE_READ_REPLY_COMPLETE) |
| 445 return RESPONSE_HEADERS_ARE_COMPLETE; | 445 return; |
| 446 | 446 |
| 447 // Save the response | 447 // Save the response |
| 448 if (!SpdyHeadersToHttpResponse(response_headers, &response_)) | 448 const bool headers_valid = |
| 449 return RESPONSE_HEADERS_ARE_INCOMPLETE; | 449 SpdyHeadersToHttpResponse(response_headers, &response_); |
| 450 DCHECK(headers_valid); | |
|
Ryan Hamilton
2016/11/23 20:58:43
ditto.
| |
| 450 | 451 |
| 451 OnIOComplete(OK); | 452 OnIOComplete(OK); |
| 452 return RESPONSE_HEADERS_ARE_COMPLETE; | |
| 453 } | 453 } |
| 454 | 454 |
| 455 // Called when data is received or on EOF (if |buffer| is NULL). | 455 // Called when data is received or on EOF (if |buffer| is NULL). |
| 456 void SpdyProxyClientSocket::OnDataReceived(std::unique_ptr<SpdyBuffer> buffer) { | 456 void SpdyProxyClientSocket::OnDataReceived(std::unique_ptr<SpdyBuffer> buffer) { |
| 457 if (buffer) { | 457 if (buffer) { |
| 458 net_log_.AddByteTransferEvent(NetLogEventType::SOCKET_BYTES_RECEIVED, | 458 net_log_.AddByteTransferEvent(NetLogEventType::SOCKET_BYTES_RECEIVED, |
| 459 buffer->GetRemainingSize(), | 459 buffer->GetRemainingSize(), |
| 460 buffer->GetRemainingData()); | 460 buffer->GetRemainingData()); |
| 461 read_buffer_queue_.Enqueue(std::move(buffer)); | 461 read_buffer_queue_.Enqueue(std::move(buffer)); |
| 462 } else { | 462 } else { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 520 } else if (!read_callback_.is_null()) { | 520 } else if (!read_callback_.is_null()) { |
| 521 // If we have a read_callback_, the we need to make sure we call it back. | 521 // If we have a read_callback_, the we need to make sure we call it back. |
| 522 OnDataReceived(std::unique_ptr<SpdyBuffer>()); | 522 OnDataReceived(std::unique_ptr<SpdyBuffer>()); |
| 523 } | 523 } |
| 524 // This may have been deleted by read_callback_, so check first. | 524 // This may have been deleted by read_callback_, so check first. |
| 525 if (weak_ptr.get() && !write_callback.is_null()) | 525 if (weak_ptr.get() && !write_callback.is_null()) |
| 526 write_callback.Run(ERR_CONNECTION_CLOSED); | 526 write_callback.Run(ERR_CONNECTION_CLOSED); |
| 527 } | 527 } |
| 528 | 528 |
| 529 } // namespace net | 529 } // namespace net |
| OLD | NEW |