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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
16 #include "net/http/http_util.h" | 16 #include "net/http/http_util.h" |
17 #include "net/quic/quic_client_promised_info.h" | 17 #include "net/quic/quic_client_promised_info.h" |
18 #include "net/quic/quic_http_utils.h" | 18 #include "net/quic/quic_http_utils.h" |
19 #include "net/quic/quic_utils.h" | 19 #include "net/quic/quic_utils.h" |
20 #include "net/quic/spdy_utils.h" | 20 #include "net/quic/spdy_utils.h" |
21 #include "net/socket/next_proto.h" | |
22 #include "net/spdy/spdy_frame_builder.h" | 21 #include "net/spdy/spdy_frame_builder.h" |
23 #include "net/spdy/spdy_framer.h" | 22 #include "net/spdy/spdy_framer.h" |
24 #include "net/spdy/spdy_http_utils.h" | 23 #include "net/spdy/spdy_http_utils.h" |
25 #include "net/ssl/ssl_info.h" | 24 #include "net/ssl/ssl_info.h" |
26 | 25 |
27 namespace net { | 26 namespace net { |
28 | 27 |
29 namespace { | 28 namespace { |
30 | 29 |
31 std::unique_ptr<base::Value> NetLogQuicPushStreamCallback( | 30 std::unique_ptr<base::Value> NetLogQuicPushStreamCallback( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const SpdyHeaderBlock& promise_response) { | 77 const SpdyHeaderBlock& promise_response) { |
79 HttpResponseInfo promise_response_info; | 78 HttpResponseInfo promise_response_info; |
80 | 79 |
81 HttpRequestInfo promise_request_info; | 80 HttpRequestInfo promise_request_info; |
82 ConvertHeaderBlockToHttpRequestHeaders(promise_request, | 81 ConvertHeaderBlockToHttpRequestHeaders(promise_request, |
83 &promise_request_info.extra_headers); | 82 &promise_request_info.extra_headers); |
84 HttpRequestInfo client_request_info; | 83 HttpRequestInfo client_request_info; |
85 ConvertHeaderBlockToHttpRequestHeaders(client_request, | 84 ConvertHeaderBlockToHttpRequestHeaders(client_request, |
86 &client_request_info.extra_headers); | 85 &client_request_info.extra_headers); |
87 | 86 |
88 if (!SpdyHeadersToHttpResponse(promise_response, HTTP2, | 87 if (!SpdyHeadersToHttpResponse(promise_response, &promise_response_info)) { |
89 &promise_response_info)) { | |
90 DLOG(WARNING) << "Invalid headers"; | 88 DLOG(WARNING) << "Invalid headers"; |
91 return false; | 89 return false; |
92 } | 90 } |
93 | 91 |
94 HttpVaryData vary_data; | 92 HttpVaryData vary_data; |
95 if (!vary_data.Init(promise_request_info, | 93 if (!vary_data.Init(promise_request_info, |
96 *promise_response_info.headers.get())) { | 94 *promise_response_info.headers.get())) { |
97 // Promise didn't contain valid vary info, so URL match was sufficient. | 95 // Promise didn't contain valid vary info, so URL match was sufficient. |
98 return true; | 96 return true; |
99 } | 97 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 request_headers.HasHeader(HttpRequestHeaders::kCookie)) { | 260 request_headers.HasHeader(HttpRequestHeaders::kCookie)) { |
263 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.CookieSentToAccountsOverChannelId", | 261 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.CookieSentToAccountsOverChannelId", |
264 ssl_info_.channel_id_sent); | 262 ssl_info_.channel_id_sent); |
265 } | 263 } |
266 if ((!found_promise_ && !stream_) || !session_) { | 264 if ((!found_promise_ && !stream_) || !session_) { |
267 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED | 265 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED |
268 : ERR_QUIC_HANDSHAKE_FAILED; | 266 : ERR_QUIC_HANDSHAKE_FAILED; |
269 } | 267 } |
270 | 268 |
271 // Store the serialized request headers. | 269 // Store the serialized request headers. |
272 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, HTTP2, | 270 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, |
273 /*direct=*/true, &request_headers_); | 271 /*direct=*/true, &request_headers_); |
274 | 272 |
275 // Store the request body. | 273 // Store the request body. |
276 request_body_stream_ = request_info_->upload_data_stream; | 274 request_body_stream_ = request_info_->upload_data_stream; |
277 if (request_body_stream_) { | 275 if (request_body_stream_) { |
278 // TODO(rch): Can we be more precise about when to allocate | 276 // TODO(rch): Can we be more precise about when to allocate |
279 // raw_request_body_buf_. Removed the following check. DoReadRequestBody() | 277 // raw_request_body_buf_. Removed the following check. DoReadRequestBody() |
280 // was being called even if we didn't yet allocate raw_request_body_buf_. | 278 // was being called even if we didn't yet allocate raw_request_body_buf_. |
281 // && (request_body_stream_->size() || | 279 // && (request_body_stream_->size() || |
282 // request_body_stream_->is_chunked())) | 280 // request_body_stream_->is_chunked())) |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 if (!request_body_stream_->IsEOF()) { | 762 if (!request_body_stream_->IsEOF()) { |
765 next_state_ = STATE_READ_REQUEST_BODY; | 763 next_state_ = STATE_READ_REQUEST_BODY; |
766 return OK; | 764 return OK; |
767 } | 765 } |
768 | 766 |
769 next_state_ = STATE_OPEN; | 767 next_state_ = STATE_OPEN; |
770 return OK; | 768 return OK; |
771 } | 769 } |
772 | 770 |
773 int QuicHttpStream::ProcessResponseHeaders(const SpdyHeaderBlock& headers) { | 771 int QuicHttpStream::ProcessResponseHeaders(const SpdyHeaderBlock& headers) { |
774 if (!SpdyHeadersToHttpResponse(headers, HTTP2, response_info_)) { | 772 if (!SpdyHeadersToHttpResponse(headers, response_info_)) { |
775 DLOG(WARNING) << "Invalid headers"; | 773 DLOG(WARNING) << "Invalid headers"; |
776 return ERR_QUIC_PROTOCOL_ERROR; | 774 return ERR_QUIC_PROTOCOL_ERROR; |
777 } | 775 } |
778 // Put the peer's IP address and port into the response. | 776 // Put the peer's IP address and port into the response. |
779 IPEndPoint address = session_->peer_address(); | 777 IPEndPoint address = session_->peer_address(); |
780 response_info_->socket_address = HostPortPair::FromIPEndPoint(address); | 778 response_info_->socket_address = HostPortPair::FromIPEndPoint(address); |
781 response_info_->connection_info = | 779 response_info_->connection_info = |
782 HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; | 780 HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; |
783 response_info_->vary_data.Init(*request_info_, | 781 response_info_->vary_data.Init(*request_info_, |
784 *response_info_->headers.get()); | 782 *response_info_->headers.get()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 817 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
820 stream_ = nullptr; | 818 stream_ = nullptr; |
821 | 819 |
822 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress | 820 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress |
823 // read. | 821 // read. |
824 if (request_body_stream_) | 822 if (request_body_stream_) |
825 request_body_stream_->Reset(); | 823 request_body_stream_->Reset(); |
826 } | 824 } |
827 | 825 |
828 } // namespace net | 826 } // namespace net |
OLD | NEW |