| 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/chromium/quic_http_stream.h" | 5 #include "net/quic/chromium/quic_http_stream.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { | 95 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { |
| 96 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); | 96 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); |
| 97 } | 97 } |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 // Subclass of QuicHttpStream that closes itself when the first piece of data | 100 // Subclass of QuicHttpStream that closes itself when the first piece of data |
| 101 // is received. | 101 // is received. |
| 102 class AutoClosingStream : public QuicHttpStream { | 102 class AutoClosingStream : public QuicHttpStream { |
| 103 public: | 103 public: |
| 104 explicit AutoClosingStream( | 104 explicit AutoClosingStream(QuicChromiumClientSession::Handle session, |
| 105 const base::WeakPtr<QuicChromiumClientSession>& session, | 105 HttpServerProperties* http_server_properties) |
| 106 HttpServerProperties* http_server_properties) | |
| 107 : QuicHttpStream(session, http_server_properties) {} | 106 : QuicHttpStream(session, http_server_properties) {} |
| 108 | 107 |
| 109 void OnHeadersAvailable(const SpdyHeaderBlock& headers, | 108 void OnHeadersAvailable(const SpdyHeaderBlock& headers, |
| 110 size_t frame_len) override { | 109 size_t frame_len) override { |
| 111 Close(false); | 110 Close(false); |
| 112 } | 111 } |
| 113 | 112 |
| 114 void OnDataAvailable() override { Close(false); } | 113 void OnDataAvailable() override { Close(false); } |
| 115 }; | 114 }; |
| 116 | 115 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 QuicServerId(kDefaultServerHostName, kDefaultServerPort, | 313 QuicServerId(kDefaultServerHostName, kDefaultServerPort, |
| 315 PRIVACY_MODE_DISABLED), | 314 PRIVACY_MODE_DISABLED), |
| 316 /*require_confirmation=*/false, kQuicYieldAfterPacketsRead, | 315 /*require_confirmation=*/false, kQuicYieldAfterPacketsRead, |
| 317 QuicTime::Delta::FromMilliseconds(kQuicYieldAfterDurationMilliseconds), | 316 QuicTime::Delta::FromMilliseconds(kQuicYieldAfterDurationMilliseconds), |
| 318 /*cert_verify_flags=*/0, DefaultQuicConfig(), &crypto_config_, | 317 /*cert_verify_flags=*/0, DefaultQuicConfig(), &crypto_config_, |
| 319 "CONNECTION_UNKNOWN", dns_start, dns_end, &push_promise_index_, nullptr, | 318 "CONNECTION_UNKNOWN", dns_start, dns_end, &push_promise_index_, nullptr, |
| 320 base::ThreadTaskRunnerHandle::Get().get(), | 319 base::ThreadTaskRunnerHandle::Get().get(), |
| 321 /*socket_performance_watcher=*/nullptr, net_log_.bound().net_log())); | 320 /*socket_performance_watcher=*/nullptr, net_log_.bound().net_log())); |
| 322 session_->Initialize(); | 321 session_->Initialize(); |
| 323 TestCompletionCallback callback; | 322 TestCompletionCallback callback; |
| 323 |
| 324 session_->CryptoConnect(callback.callback()); | 324 session_->CryptoConnect(callback.callback()); |
| 325 stream_.reset(use_closing_stream_ | 325 stream_.reset(use_closing_stream_ |
| 326 ? new AutoClosingStream(session_->GetWeakPtr(), | 326 ? new AutoClosingStream(session_->GetHandle(), |
| 327 &http_server_properties_) | 327 &http_server_properties_) |
| 328 : new QuicHttpStream(session_->GetWeakPtr(), | 328 : new QuicHttpStream(session_->GetHandle(), |
| 329 &http_server_properties_)); | 329 &http_server_properties_)); |
| 330 | 330 |
| 331 promised_stream_.reset(use_closing_stream_ | 331 promised_stream_.reset(use_closing_stream_ |
| 332 ? new AutoClosingStream(session_->GetWeakPtr(), | 332 ? new AutoClosingStream(session_->GetHandle(), |
| 333 &http_server_properties_) | 333 &http_server_properties_) |
| 334 : new QuicHttpStream(session_->GetWeakPtr(), | 334 : new QuicHttpStream(session_->GetHandle(), |
| 335 &http_server_properties_)); | 335 &http_server_properties_)); |
| 336 | 336 |
| 337 push_promise_[":path"] = "/bar"; | 337 push_promise_[":path"] = "/bar"; |
| 338 push_promise_[":authority"] = "www.example.org"; | 338 push_promise_[":authority"] = "www.example.org"; |
| 339 push_promise_[":version"] = "HTTP/1.1"; | 339 push_promise_[":version"] = "HTTP/1.1"; |
| 340 push_promise_[":method"] = "GET"; | 340 push_promise_[":method"] = "GET"; |
| 341 push_promise_[":scheme"] = "https"; | 341 push_promise_[":scheme"] = "https"; |
| 342 | 342 |
| 343 promised_response_[":status"] = "200 OK"; | 343 promised_response_[":status"] = "200 OK"; |
| 344 promised_response_[":version"] = "HTTP/1.1"; | 344 promised_response_[":version"] = "HTTP/1.1"; |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 request_.method = "GET"; | 704 request_.method = "GET"; |
| 705 request_.url = GURL("https://www.example.org/"); | 705 request_.url = GURL("https://www.example.org/"); |
| 706 // Start first request. | 706 // Start first request. |
| 707 EXPECT_EQ(OK, | 707 EXPECT_EQ(OK, |
| 708 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 708 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 709 net_log_.bound(), callback_.callback())); | 709 net_log_.bound(), callback_.callback())); |
| 710 EXPECT_EQ(OK, | 710 EXPECT_EQ(OK, |
| 711 stream_->SendRequest(headers_, &response_, callback_.callback())); | 711 stream_->SendRequest(headers_, &response_, callback_.callback())); |
| 712 | 712 |
| 713 // Start a second request. | 713 // Start a second request. |
| 714 QuicHttpStream stream2(session_->GetWeakPtr(), &http_server_properties_); | 714 QuicHttpStream stream2(session_->GetHandle(), &http_server_properties_); |
| 715 TestCompletionCallback callback2; | 715 TestCompletionCallback callback2; |
| 716 EXPECT_EQ(OK, | 716 EXPECT_EQ(OK, |
| 717 stream2.InitializeStream(&request_, DEFAULT_PRIORITY, | 717 stream2.InitializeStream(&request_, DEFAULT_PRIORITY, |
| 718 net_log_.bound(), callback2.callback())); | 718 net_log_.bound(), callback2.callback())); |
| 719 EXPECT_EQ(OK, | 719 EXPECT_EQ(OK, |
| 720 stream2.SendRequest(headers_, &response_, callback2.callback())); | 720 stream2.SendRequest(headers_, &response_, callback2.callback())); |
| 721 | 721 |
| 722 // Ack both requests. | 722 // Ack both requests. |
| 723 ProcessPacket(ConstructServerAckPacket(1, 0, 0, 0)); | 723 ProcessPacket(ConstructServerAckPacket(1, 0, 0, 0)); |
| 724 | 724 |
| (...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 EXPECT_TRUE(AtEof()); | 2140 EXPECT_TRUE(AtEof()); |
| 2141 | 2141 |
| 2142 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. | 2142 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. |
| 2143 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), | 2143 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), |
| 2144 stream_->GetTotalSentBytes()); | 2144 stream_->GetTotalSentBytes()); |
| 2145 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | 2145 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
| 2146 } | 2146 } |
| 2147 | 2147 |
| 2148 } // namespace test | 2148 } // namespace test |
| 2149 } // namespace net | 2149 } // namespace net |
| OLD | NEW |