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/quic/quic_http_stream.h" | 5 #include "net/quic/quic_http_stream.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 | 630 |
631 int QuicHttpStream::DoSendHeaders() { | 631 int QuicHttpStream::DoSendHeaders() { |
632 if (!stream_) | 632 if (!stream_) |
633 return ERR_UNEXPECTED; | 633 return ERR_UNEXPECTED; |
634 | 634 |
635 // Log the actual request with the URL Request's net log. | 635 // Log the actual request with the URL Request's net log. |
636 stream_net_log_.AddEvent( | 636 stream_net_log_.AddEvent( |
637 NetLog::TYPE_HTTP_TRANSACTION_QUIC_SEND_REQUEST_HEADERS, | 637 NetLog::TYPE_HTTP_TRANSACTION_QUIC_SEND_REQUEST_HEADERS, |
638 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_, | 638 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_, |
639 priority_)); | 639 priority_)); |
640 // Also log to the QuicSession's net log. | |
641 stream_->net_log().AddEvent( | |
642 NetLog::TYPE_QUIC_HTTP_STREAM_SEND_REQUEST_HEADERS, | |
643 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_, | |
644 priority_)); | |
645 | |
646 bool has_upload_data = request_body_stream_ != nullptr; | 640 bool has_upload_data = request_body_stream_ != nullptr; |
647 | 641 |
648 next_state_ = STATE_SEND_HEADERS_COMPLETE; | 642 next_state_ = STATE_SEND_HEADERS_COMPLETE; |
649 size_t frame_len = | 643 size_t frame_len = |
650 stream_->WriteHeaders(request_headers_, !has_upload_data, nullptr); | 644 stream_->WriteHeaders(request_headers_, !has_upload_data, nullptr); |
651 headers_bytes_sent_ += frame_len; | 645 headers_bytes_sent_ += frame_len; |
652 | 646 |
653 request_headers_.clear(); | 647 request_headers_.clear(); |
654 return static_cast<int>(frame_len); | 648 return static_cast<int>(frame_len); |
655 } | 649 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 if (!request_body_stream_->IsEOF()) { | 720 if (!request_body_stream_->IsEOF()) { |
727 next_state_ = STATE_READ_REQUEST_BODY; | 721 next_state_ = STATE_READ_REQUEST_BODY; |
728 return OK; | 722 return OK; |
729 } | 723 } |
730 | 724 |
731 next_state_ = STATE_OPEN; | 725 next_state_ = STATE_OPEN; |
732 return OK; | 726 return OK; |
733 } | 727 } |
734 | 728 |
735 int QuicHttpStream::ProcessResponseHeaders(const SpdyHeaderBlock& headers) { | 729 int QuicHttpStream::ProcessResponseHeaders(const SpdyHeaderBlock& headers) { |
736 // The URLRequest logs these headers, so only log to the QuicSession's | |
737 // net log. | |
738 stream_->net_log().AddEvent( | |
739 NetLog::TYPE_QUIC_HTTP_STREAM_READ_RESPONSE_HEADERS, | |
740 base::Bind(&SpdyHeaderBlockNetLogCallback, &headers)); | |
741 | |
742 if (!SpdyHeadersToHttpResponse(headers, HTTP2, response_info_)) { | 730 if (!SpdyHeadersToHttpResponse(headers, HTTP2, response_info_)) { |
743 DLOG(WARNING) << "Invalid headers"; | 731 DLOG(WARNING) << "Invalid headers"; |
744 return ERR_QUIC_PROTOCOL_ERROR; | 732 return ERR_QUIC_PROTOCOL_ERROR; |
745 } | 733 } |
746 // Put the peer's IP address and port into the response. | 734 // Put the peer's IP address and port into the response. |
747 IPEndPoint address = session_->peer_address(); | 735 IPEndPoint address = session_->peer_address(); |
748 response_info_->socket_address = HostPortPair::FromIPEndPoint(address); | 736 response_info_->socket_address = HostPortPair::FromIPEndPoint(address); |
749 response_info_->connection_info = | 737 response_info_->connection_info = |
750 HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; | 738 HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; |
751 response_info_->vary_data.Init(*request_info_, | 739 response_info_->vary_data.Init(*request_info_, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 775 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
788 stream_ = nullptr; | 776 stream_ = nullptr; |
789 | 777 |
790 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress | 778 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress |
791 // read. | 779 // read. |
792 if (request_body_stream_) | 780 if (request_body_stream_) |
793 request_body_stream_->Reset(); | 781 request_body_stream_->Reset(); |
794 } | 782 } |
795 | 783 |
796 } // namespace net | 784 } // namespace net |
OLD | NEW |