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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "net/base/chunked_upload_data_stream.h" | 14 #include "net/base/chunked_upload_data_stream.h" |
15 #include "net/base/elements_upload_data_stream.h" | 15 #include "net/base/elements_upload_data_stream.h" |
16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
17 #include "net/base/socket_performance_watcher.h" | 17 #include "net/base/socket_performance_watcher.h" |
18 #include "net/base/test_completion_callback.h" | 18 #include "net/base/test_completion_callback.h" |
19 #include "net/base/test_data_directory.h" | 19 #include "net/base/test_data_directory.h" |
20 #include "net/base/upload_bytes_element_reader.h" | 20 #include "net/base/upload_bytes_element_reader.h" |
21 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
22 #include "net/http/transport_security_state.h" | 22 #include "net/http/transport_security_state.h" |
| 23 #include "net/log/test_net_log.h" |
| 24 #include "net/log/test_net_log_util.h" |
23 #include "net/quic/congestion_control/send_algorithm_interface.h" | 25 #include "net/quic/congestion_control/send_algorithm_interface.h" |
24 #include "net/quic/crypto/crypto_protocol.h" | 26 #include "net/quic/crypto/crypto_protocol.h" |
25 #include "net/quic/crypto/proof_verifier_chromium.h" | 27 #include "net/quic/crypto/proof_verifier_chromium.h" |
26 #include "net/quic/crypto/quic_decrypter.h" | 28 #include "net/quic/crypto/quic_decrypter.h" |
27 #include "net/quic/crypto/quic_encrypter.h" | 29 #include "net/quic/crypto/quic_encrypter.h" |
28 #include "net/quic/crypto/quic_server_info.h" | 30 #include "net/quic/crypto/quic_server_info.h" |
29 #include "net/quic/quic_chromium_client_session.h" | 31 #include "net/quic/quic_chromium_client_session.h" |
30 #include "net/quic/quic_chromium_client_stream.h" | 32 #include "net/quic/quic_chromium_client_stream.h" |
31 #include "net/quic/quic_chromium_connection_helper.h" | 33 #include "net/quic/quic_chromium_connection_helper.h" |
32 #include "net/quic/quic_chromium_packet_reader.h" | 34 #include "net/quic/quic_chromium_packet_reader.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 struct PacketToWrite { | 131 struct PacketToWrite { |
130 PacketToWrite(IoMode mode, QuicEncryptedPacket* packet) | 132 PacketToWrite(IoMode mode, QuicEncryptedPacket* packet) |
131 : mode(mode), packet(packet) {} | 133 : mode(mode), packet(packet) {} |
132 PacketToWrite(IoMode mode, int rv) : mode(mode), packet(nullptr), rv(rv) {} | 134 PacketToWrite(IoMode mode, int rv) : mode(mode), packet(nullptr), rv(rv) {} |
133 IoMode mode; | 135 IoMode mode; |
134 QuicEncryptedPacket* packet; | 136 QuicEncryptedPacket* packet; |
135 int rv; | 137 int rv; |
136 }; | 138 }; |
137 | 139 |
138 QuicHttpStreamTest() | 140 QuicHttpStreamTest() |
139 : net_log_(BoundNetLog()), | 141 : use_closing_stream_(false), |
140 use_closing_stream_(false), | |
141 crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), | 142 crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), |
142 read_buffer_(new IOBufferWithSize(4096)), | 143 read_buffer_(new IOBufferWithSize(4096)), |
143 promise_id_(kServerDataStreamId1), | 144 promise_id_(kServerDataStreamId1), |
144 stream_id_(kClientDataStreamId1), | 145 stream_id_(kClientDataStreamId1), |
145 connection_id_(2), | 146 connection_id_(2), |
146 maker_(GetParam(), connection_id_, &clock_, kDefaultServerHostName), | 147 maker_(GetParam(), connection_id_, &clock_, kDefaultServerHostName), |
147 random_generator_(0), | 148 random_generator_(0), |
148 response_offset_(0) { | 149 response_offset_(0) { |
149 IPAddress ip(192, 0, 2, 33); | 150 IPAddress ip(192, 0, 2, 33); |
150 peer_addr_ = IPEndPoint(ip, 443); | 151 peer_addr_ = IPEndPoint(ip, 443); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } else { | 190 } else { |
190 mock_writes_[i] = MockWrite(writes_[i].mode, writes_[i].packet->data(), | 191 mock_writes_[i] = MockWrite(writes_[i].mode, writes_[i].packet->data(), |
191 writes_[i].packet->length()); | 192 writes_[i].packet->length()); |
192 } | 193 } |
193 }; | 194 }; |
194 | 195 |
195 socket_data_.reset(new StaticSocketDataProvider( | 196 socket_data_.reset(new StaticSocketDataProvider( |
196 nullptr, 0, mock_writes_.get(), writes_.size())); | 197 nullptr, 0, mock_writes_.get(), writes_.size())); |
197 | 198 |
198 MockUDPClientSocket* socket = | 199 MockUDPClientSocket* socket = |
199 new MockUDPClientSocket(socket_data_.get(), net_log_.net_log()); | 200 new MockUDPClientSocket(socket_data_.get(), net_log_.bound().net_log()); |
200 socket->Connect(peer_addr_); | 201 socket->Connect(peer_addr_); |
201 runner_ = new TestTaskRunner(&clock_); | 202 runner_ = new TestTaskRunner(&clock_); |
202 send_algorithm_ = new MockSendAlgorithm(); | 203 send_algorithm_ = new MockSendAlgorithm(); |
203 EXPECT_CALL(*send_algorithm_, InRecovery()).WillRepeatedly(Return(false)); | 204 EXPECT_CALL(*send_algorithm_, InRecovery()).WillRepeatedly(Return(false)); |
204 EXPECT_CALL(*send_algorithm_, InSlowStart()).WillRepeatedly(Return(false)); | 205 EXPECT_CALL(*send_algorithm_, InSlowStart()).WillRepeatedly(Return(false)); |
205 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 206 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
206 .WillRepeatedly(Return(true)); | 207 .WillRepeatedly(Return(true)); |
207 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) | 208 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) |
208 .WillRepeatedly(Return(QuicTime::Delta::Zero())); | 209 .WillRepeatedly(Return(QuicTime::Delta::Zero())); |
209 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) | 210 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) |
(...skipping 26 matching lines...) Expand all Loading... |
236 connection_, scoped_ptr<DatagramClientSocket>(socket), | 237 connection_, scoped_ptr<DatagramClientSocket>(socket), |
237 /*stream_factory=*/nullptr, &crypto_client_stream_factory_, &clock_, | 238 /*stream_factory=*/nullptr, &crypto_client_stream_factory_, &clock_, |
238 &transport_security_state_, make_scoped_ptr((QuicServerInfo*)nullptr), | 239 &transport_security_state_, make_scoped_ptr((QuicServerInfo*)nullptr), |
239 QuicServerId(kDefaultServerHostName, kDefaultServerPort, | 240 QuicServerId(kDefaultServerHostName, kDefaultServerPort, |
240 PRIVACY_MODE_DISABLED), | 241 PRIVACY_MODE_DISABLED), |
241 kQuicYieldAfterPacketsRead, | 242 kQuicYieldAfterPacketsRead, |
242 QuicTime::Delta::FromMilliseconds(kQuicYieldAfterDurationMilliseconds), | 243 QuicTime::Delta::FromMilliseconds(kQuicYieldAfterDurationMilliseconds), |
243 /*cert_verify_flags=*/0, DefaultQuicConfig(), &crypto_config_, | 244 /*cert_verify_flags=*/0, DefaultQuicConfig(), &crypto_config_, |
244 "CONNECTION_UNKNOWN", base::TimeTicks::Now(), &push_promise_index_, | 245 "CONNECTION_UNKNOWN", base::TimeTicks::Now(), &push_promise_index_, |
245 base::ThreadTaskRunnerHandle::Get().get(), | 246 base::ThreadTaskRunnerHandle::Get().get(), |
246 /*socket_performance_watcher=*/nullptr, nullptr)); | 247 /*socket_performance_watcher=*/nullptr, net_log_.bound().net_log())); |
247 session_->Initialize(); | 248 session_->Initialize(); |
248 session_->GetCryptoStream()->CryptoConnect(); | 249 session_->GetCryptoStream()->CryptoConnect(); |
249 EXPECT_TRUE(session_->IsCryptoHandshakeConfirmed()); | 250 EXPECT_TRUE(session_->IsCryptoHandshakeConfirmed()); |
250 stream_.reset(use_closing_stream_ | 251 stream_.reset(use_closing_stream_ |
251 ? new AutoClosingStream(session_->GetWeakPtr()) | 252 ? new AutoClosingStream(session_->GetWeakPtr()) |
252 : new QuicHttpStream(session_->GetWeakPtr())); | 253 : new QuicHttpStream(session_->GetWeakPtr())); |
253 | 254 |
254 promised_stream_.reset(use_closing_stream_ | 255 promised_stream_.reset(use_closing_stream_ |
255 ? new AutoClosingStream(session_->GetWeakPtr()) | 256 ? new AutoClosingStream(session_->GetWeakPtr()) |
256 : new QuicHttpStream(session_->GetWeakPtr())); | 257 : new QuicHttpStream(session_->GetWeakPtr())); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 411 } |
411 | 412 |
412 void ReceivePromise(QuicStreamId id) { | 413 void ReceivePromise(QuicStreamId id) { |
413 QuicChromiumClientStream* stream = | 414 QuicChromiumClientStream* stream = |
414 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); | 415 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); |
415 stream->OnStreamHeaders(serialized_push_promise_); | 416 stream->OnStreamHeaders(serialized_push_promise_); |
416 | 417 |
417 stream->OnPromiseHeadersComplete(id, serialized_push_promise_.size()); | 418 stream->OnPromiseHeadersComplete(id, serialized_push_promise_.size()); |
418 } | 419 } |
419 | 420 |
420 BoundNetLog net_log_; | 421 BoundTestNetLog net_log_; |
421 bool use_closing_stream_; | 422 bool use_closing_stream_; |
422 MockSendAlgorithm* send_algorithm_; | 423 MockSendAlgorithm* send_algorithm_; |
423 scoped_refptr<TestTaskRunner> runner_; | 424 scoped_refptr<TestTaskRunner> runner_; |
424 scoped_ptr<MockWrite[]> mock_writes_; | 425 scoped_ptr<MockWrite[]> mock_writes_; |
425 MockClock clock_; | 426 MockClock clock_; |
426 TestQuicConnection* connection_; | 427 TestQuicConnection* connection_; |
427 scoped_ptr<QuicChromiumConnectionHelper> helper_; | 428 scoped_ptr<QuicChromiumConnectionHelper> helper_; |
428 testing::StrictMock<MockConnectionVisitor> visitor_; | 429 testing::StrictMock<MockConnectionVisitor> visitor_; |
429 scoped_ptr<QuicHttpStream> stream_; | 430 scoped_ptr<QuicHttpStream> stream_; |
430 TransportSecurityState transport_security_state_; | 431 TransportSecurityState transport_security_state_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 474 } |
474 | 475 |
475 TEST_P(QuicHttpStreamTest, CanReuseConnection) { | 476 TEST_P(QuicHttpStreamTest, CanReuseConnection) { |
476 Initialize(); | 477 Initialize(); |
477 EXPECT_FALSE(stream_->CanReuseConnection()); | 478 EXPECT_FALSE(stream_->CanReuseConnection()); |
478 } | 479 } |
479 | 480 |
480 TEST_P(QuicHttpStreamTest, DisableConnectionMigrationForStream) { | 481 TEST_P(QuicHttpStreamTest, DisableConnectionMigrationForStream) { |
481 request_.load_flags |= LOAD_DISABLE_CONNECTION_MIGRATION; | 482 request_.load_flags |= LOAD_DISABLE_CONNECTION_MIGRATION; |
482 Initialize(); | 483 Initialize(); |
483 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 484 EXPECT_EQ(OK, |
484 callback_.callback())); | 485 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 486 net_log_.bound(), callback_.callback())); |
485 QuicChromiumClientStream* client_stream = | 487 QuicChromiumClientStream* client_stream = |
486 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); | 488 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); |
487 EXPECT_FALSE(client_stream->can_migrate()); | 489 EXPECT_FALSE(client_stream->can_migrate()); |
488 } | 490 } |
489 | 491 |
490 TEST_P(QuicHttpStreamTest, GetRequest) { | 492 TEST_P(QuicHttpStreamTest, GetRequest) { |
491 SetRequest("GET", "/", DEFAULT_PRIORITY); | 493 SetRequest("GET", "/", DEFAULT_PRIORITY); |
492 size_t spdy_request_header_frame_length; | 494 size_t spdy_request_header_frame_length; |
493 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, | 495 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, |
494 &spdy_request_header_frame_length)); | 496 &spdy_request_header_frame_length)); |
495 Initialize(); | 497 Initialize(); |
496 | 498 |
497 request_.method = "GET"; | 499 request_.method = "GET"; |
498 request_.url = GURL("http://www.example.org/"); | 500 request_.url = GURL("http://www.example.org/"); |
499 | 501 |
500 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 502 EXPECT_EQ(OK, |
501 callback_.callback())); | 503 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 504 net_log_.bound(), callback_.callback())); |
502 EXPECT_EQ(OK, | 505 EXPECT_EQ(OK, |
503 stream_->SendRequest(headers_, &response_, callback_.callback())); | 506 stream_->SendRequest(headers_, &response_, callback_.callback())); |
504 | 507 |
505 // Ack the request. | 508 // Ack the request. |
506 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 509 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
507 | 510 |
508 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 511 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); |
509 | 512 |
510 SetResponse("404 Not Found", std::string()); | 513 SetResponse("404 Not Found", std::string()); |
511 size_t spdy_response_header_frame_length; | 514 size_t spdy_response_header_frame_length; |
(...skipping 30 matching lines...) Expand all Loading... |
542 size_t spdy_request_header_frame_length; | 545 size_t spdy_request_header_frame_length; |
543 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, | 546 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, |
544 &spdy_request_header_frame_length)); | 547 &spdy_request_header_frame_length)); |
545 AddWrite(ConstructAckPacket(2, 3, 1)); // Ack the data packet. | 548 AddWrite(ConstructAckPacket(2, 3, 1)); // Ack the data packet. |
546 | 549 |
547 Initialize(); | 550 Initialize(); |
548 | 551 |
549 request_.method = "GET"; | 552 request_.method = "GET"; |
550 request_.url = GURL("http://www.example.org/"); | 553 request_.url = GURL("http://www.example.org/"); |
551 | 554 |
552 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 555 EXPECT_EQ(OK, |
553 callback_.callback())); | 556 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 557 net_log_.bound(), callback_.callback())); |
| 558 |
554 EXPECT_EQ(OK, | 559 EXPECT_EQ(OK, |
555 stream_->SendRequest(headers_, &response_, callback_.callback())); | 560 stream_->SendRequest(headers_, &response_, callback_.callback())); |
556 | 561 |
557 // Ack the request. | 562 // Ack the request. |
558 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 563 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
559 | 564 |
560 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 565 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); |
561 | 566 |
562 SetResponse("200 OK", std::string()); | 567 SetResponse("200 OK", std::string()); |
563 | 568 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 EXPECT_TRUE(AtEof()); | 606 EXPECT_TRUE(AtEof()); |
602 | 607 |
603 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | 608 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
604 // headers and payload. | 609 // headers and payload. |
605 EXPECT_EQ(static_cast<int64_t>(spdy_request_header_frame_length), | 610 EXPECT_EQ(static_cast<int64_t>(spdy_request_header_frame_length), |
606 stream_->GetTotalSentBytes()); | 611 stream_->GetTotalSentBytes()); |
607 EXPECT_EQ( | 612 EXPECT_EQ( |
608 static_cast<int64_t>(spdy_response_header_frame_length + | 613 static_cast<int64_t>(spdy_response_header_frame_length + |
609 strlen(kResponseBody) + +spdy_trailers_frame_length), | 614 strlen(kResponseBody) + +spdy_trailers_frame_length), |
610 stream_->GetTotalReceivedBytes()); | 615 stream_->GetTotalReceivedBytes()); |
| 616 // Check that NetLog was filled as expected. |
| 617 TestNetLogEntry::List entries; |
| 618 net_log_.GetEntries(&entries); |
| 619 size_t pos = ExpectLogContainsSomewhere( |
| 620 entries, /*min_offset=*/0, |
| 621 NetLog::TYPE_QUIC_CHROMIUM_CLIENT_STREAM_SEND_REQUEST_HEADERS, |
| 622 NetLog::PHASE_NONE); |
| 623 pos = ExpectLogContainsSomewhere( |
| 624 entries, /*min_offset=*/pos, |
| 625 NetLog::TYPE_QUIC_CHROMIUM_CLIENT_STREAM_SEND_REQUEST_HEADERS, |
| 626 NetLog::PHASE_NONE); |
| 627 ExpectLogContainsSomewhere( |
| 628 entries, /*min_offset=*/pos, |
| 629 NetLog::TYPE_QUIC_CHROMIUM_CLIENT_STREAM_SEND_REQUEST_HEADERS, |
| 630 NetLog::PHASE_NONE); |
611 } | 631 } |
612 | 632 |
613 // Regression test for http://crbug.com/288128 | 633 // Regression test for http://crbug.com/288128 |
614 TEST_P(QuicHttpStreamTest, GetRequestLargeResponse) { | 634 TEST_P(QuicHttpStreamTest, GetRequestLargeResponse) { |
615 SetRequest("GET", "/", DEFAULT_PRIORITY); | 635 SetRequest("GET", "/", DEFAULT_PRIORITY); |
616 size_t spdy_request_headers_frame_length; | 636 size_t spdy_request_headers_frame_length; |
617 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, | 637 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, |
618 &spdy_request_headers_frame_length)); | 638 &spdy_request_headers_frame_length)); |
619 Initialize(); | 639 Initialize(); |
620 | 640 |
621 request_.method = "GET"; | 641 request_.method = "GET"; |
622 request_.url = GURL("http://www.example.org/"); | 642 request_.url = GURL("http://www.example.org/"); |
623 | 643 |
624 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 644 EXPECT_EQ(OK, |
625 callback_.callback())); | 645 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 646 net_log_.bound(), callback_.callback())); |
626 EXPECT_EQ(OK, | 647 EXPECT_EQ(OK, |
627 stream_->SendRequest(headers_, &response_, callback_.callback())); | 648 stream_->SendRequest(headers_, &response_, callback_.callback())); |
628 | 649 |
629 // Ack the request. | 650 // Ack the request. |
630 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 651 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
631 | 652 |
632 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 653 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); |
633 | 654 |
634 SpdyHeaderBlock headers; | 655 SpdyHeaderBlock headers; |
635 headers[":status"] = "200 OK"; | 656 headers[":status"] = "200 OK"; |
(...skipping 28 matching lines...) Expand all Loading... |
664 } | 685 } |
665 | 686 |
666 // Regression test for http://crbug.com/409101 | 687 // Regression test for http://crbug.com/409101 |
667 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendRequest) { | 688 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendRequest) { |
668 SetRequest("GET", "/", DEFAULT_PRIORITY); | 689 SetRequest("GET", "/", DEFAULT_PRIORITY); |
669 Initialize(); | 690 Initialize(); |
670 | 691 |
671 request_.method = "GET"; | 692 request_.method = "GET"; |
672 request_.url = GURL("http://www.example.org/"); | 693 request_.url = GURL("http://www.example.org/"); |
673 | 694 |
674 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 695 EXPECT_EQ(OK, |
675 callback_.callback())); | 696 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 697 net_log_.bound(), callback_.callback())); |
676 | 698 |
677 session_->connection()->CloseConnection(QUIC_NO_ERROR, | 699 session_->connection()->CloseConnection(QUIC_NO_ERROR, |
678 ConnectionCloseSource::FROM_PEER); | 700 ConnectionCloseSource::FROM_PEER); |
679 | 701 |
680 EXPECT_EQ(ERR_CONNECTION_CLOSED, | 702 EXPECT_EQ(ERR_CONNECTION_CLOSED, |
681 stream_->SendRequest(headers_, &response_, callback_.callback())); | 703 stream_->SendRequest(headers_, &response_, callback_.callback())); |
682 | 704 |
683 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | 705 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
684 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | 706 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
685 } | 707 } |
686 | 708 |
687 // Regression test for http://crbug.com/584441 | 709 // Regression test for http://crbug.com/584441 |
688 TEST_P(QuicHttpStreamTest, GetSSLInfoAfterSessionClosed) { | 710 TEST_P(QuicHttpStreamTest, GetSSLInfoAfterSessionClosed) { |
689 SetRequest("GET", "/", DEFAULT_PRIORITY); | 711 SetRequest("GET", "/", DEFAULT_PRIORITY); |
690 Initialize(); | 712 Initialize(); |
691 | 713 |
692 request_.method = "GET"; | 714 request_.method = "GET"; |
693 request_.url = GURL("http://www.example.org/"); | 715 request_.url = GURL("http://www.example.org/"); |
694 | 716 |
695 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 717 EXPECT_EQ(OK, |
696 callback_.callback())); | 718 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 719 net_log_.bound(), callback_.callback())); |
697 | 720 |
698 SSLInfo ssl_info; | 721 SSLInfo ssl_info; |
699 EXPECT_FALSE(ssl_info.is_valid()); | 722 EXPECT_FALSE(ssl_info.is_valid()); |
700 stream_->GetSSLInfo(&ssl_info); | 723 stream_->GetSSLInfo(&ssl_info); |
701 EXPECT_TRUE(ssl_info.is_valid()); | 724 EXPECT_TRUE(ssl_info.is_valid()); |
702 | 725 |
703 session_->connection()->CloseConnection(QUIC_NO_ERROR, | 726 session_->connection()->CloseConnection(QUIC_NO_ERROR, |
704 ConnectionCloseSource::FROM_PEER); | 727 ConnectionCloseSource::FROM_PEER); |
705 | 728 |
706 SSLInfo ssl_info2; | 729 SSLInfo ssl_info2; |
707 stream_->GetSSLInfo(&ssl_info2); | 730 stream_->GetSSLInfo(&ssl_info2); |
708 EXPECT_TRUE(ssl_info2.is_valid()); | 731 EXPECT_TRUE(ssl_info2.is_valid()); |
709 } | 732 } |
710 | 733 |
711 TEST_P(QuicHttpStreamTest, LogGranularQuicConnectionError) { | 734 TEST_P(QuicHttpStreamTest, LogGranularQuicConnectionError) { |
712 SetRequest("GET", "/", DEFAULT_PRIORITY); | 735 SetRequest("GET", "/", DEFAULT_PRIORITY); |
713 size_t spdy_request_headers_frame_length; | 736 size_t spdy_request_headers_frame_length; |
714 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, | 737 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, |
715 &spdy_request_headers_frame_length)); | 738 &spdy_request_headers_frame_length)); |
716 AddWrite(ConstructAckAndRstStreamPacket(2)); | 739 AddWrite(ConstructAckAndRstStreamPacket(2)); |
717 use_closing_stream_ = true; | 740 use_closing_stream_ = true; |
718 Initialize(); | 741 Initialize(); |
719 | 742 |
720 request_.method = "GET"; | 743 request_.method = "GET"; |
721 request_.url = GURL("http://www.example.org/"); | 744 request_.url = GURL("http://www.example.org/"); |
722 | 745 |
723 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 746 EXPECT_EQ(OK, |
724 callback_.callback())); | 747 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 748 net_log_.bound(), callback_.callback())); |
725 EXPECT_EQ(OK, | 749 EXPECT_EQ(OK, |
726 stream_->SendRequest(headers_, &response_, callback_.callback())); | 750 stream_->SendRequest(headers_, &response_, callback_.callback())); |
727 | 751 |
728 // Ack the request. | 752 // Ack the request. |
729 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 753 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
730 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 754 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); |
731 | 755 |
732 EXPECT_TRUE(QuicHttpStreamPeer::WasHandshakeConfirmed(stream_.get())); | 756 EXPECT_TRUE(QuicHttpStreamPeer::WasHandshakeConfirmed(stream_.get())); |
733 stream_->OnClose(QUIC_PEER_GOING_AWAY); | 757 stream_->OnClose(QUIC_PEER_GOING_AWAY); |
734 | 758 |
735 NetErrorDetails details; | 759 NetErrorDetails details; |
736 EXPECT_EQ(QUIC_NO_ERROR, details.quic_connection_error); | 760 EXPECT_EQ(QUIC_NO_ERROR, details.quic_connection_error); |
737 stream_->PopulateNetErrorDetails(&details); | 761 stream_->PopulateNetErrorDetails(&details); |
738 EXPECT_EQ(QUIC_PEER_GOING_AWAY, details.quic_connection_error); | 762 EXPECT_EQ(QUIC_PEER_GOING_AWAY, details.quic_connection_error); |
739 } | 763 } |
740 | 764 |
741 TEST_P(QuicHttpStreamTest, DoNotLogGranularQuicErrorIfHandshakeNotConfirmed) { | 765 TEST_P(QuicHttpStreamTest, DoNotLogGranularQuicErrorIfHandshakeNotConfirmed) { |
742 SetRequest("GET", "/", DEFAULT_PRIORITY); | 766 SetRequest("GET", "/", DEFAULT_PRIORITY); |
743 size_t spdy_request_headers_frame_length; | 767 size_t spdy_request_headers_frame_length; |
744 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, | 768 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, |
745 &spdy_request_headers_frame_length)); | 769 &spdy_request_headers_frame_length)); |
746 AddWrite(ConstructAckAndRstStreamPacket(2)); | 770 AddWrite(ConstructAckAndRstStreamPacket(2)); |
747 use_closing_stream_ = true; | 771 use_closing_stream_ = true; |
748 Initialize(); | 772 Initialize(); |
749 | 773 |
750 request_.method = "GET"; | 774 request_.method = "GET"; |
751 request_.url = GURL("http://www.example.org/"); | 775 request_.url = GURL("http://www.example.org/"); |
752 | 776 |
753 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 777 EXPECT_EQ(OK, |
754 callback_.callback())); | 778 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 779 net_log_.bound(), callback_.callback())); |
755 EXPECT_EQ(OK, | 780 EXPECT_EQ(OK, |
756 stream_->SendRequest(headers_, &response_, callback_.callback())); | 781 stream_->SendRequest(headers_, &response_, callback_.callback())); |
757 | 782 |
758 // Ack the request. | 783 // Ack the request. |
759 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 784 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
760 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 785 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); |
761 | 786 |
762 // The test setup defaults handshake to be confirmed. Manually set | 787 // The test setup defaults handshake to be confirmed. Manually set |
763 // it to be not confirmed. | 788 // it to be not confirmed. |
764 // Granular errors shouldn't be reported if handshake not confirmed. | 789 // Granular errors shouldn't be reported if handshake not confirmed. |
(...skipping 12 matching lines...) Expand all Loading... |
777 TEST_P(QuicHttpStreamTest, SessionClosedBeforeReadResponseHeaders) { | 802 TEST_P(QuicHttpStreamTest, SessionClosedBeforeReadResponseHeaders) { |
778 SetRequest("GET", "/", DEFAULT_PRIORITY); | 803 SetRequest("GET", "/", DEFAULT_PRIORITY); |
779 size_t spdy_request_headers_frame_length; | 804 size_t spdy_request_headers_frame_length; |
780 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, | 805 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, |
781 &spdy_request_headers_frame_length)); | 806 &spdy_request_headers_frame_length)); |
782 Initialize(); | 807 Initialize(); |
783 | 808 |
784 request_.method = "GET"; | 809 request_.method = "GET"; |
785 request_.url = GURL("http://www.example.org/"); | 810 request_.url = GURL("http://www.example.org/"); |
786 | 811 |
787 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 812 EXPECT_EQ(OK, |
788 callback_.callback())); | 813 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 814 net_log_.bound(), callback_.callback())); |
789 | 815 |
790 EXPECT_EQ(OK, | 816 EXPECT_EQ(OK, |
791 stream_->SendRequest(headers_, &response_, callback_.callback())); | 817 stream_->SendRequest(headers_, &response_, callback_.callback())); |
792 | 818 |
793 session_->connection()->CloseConnection(QUIC_NO_ERROR, | 819 session_->connection()->CloseConnection(QUIC_NO_ERROR, |
794 ConnectionCloseSource::FROM_PEER); | 820 ConnectionCloseSource::FROM_PEER); |
795 | 821 |
796 EXPECT_NE(OK, stream_->ReadResponseHeaders(callback_.callback())); | 822 EXPECT_NE(OK, stream_->ReadResponseHeaders(callback_.callback())); |
797 | 823 |
798 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | 824 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
(...skipping 15 matching lines...) Expand all Loading... |
814 | 840 |
815 std::vector<scoped_ptr<UploadElementReader>> element_readers; | 841 std::vector<scoped_ptr<UploadElementReader>> element_readers; |
816 element_readers.push_back(make_scoped_ptr( | 842 element_readers.push_back(make_scoped_ptr( |
817 new UploadBytesElementReader(kUploadData, strlen(kUploadData)))); | 843 new UploadBytesElementReader(kUploadData, strlen(kUploadData)))); |
818 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 844 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); |
819 request_.method = "POST"; | 845 request_.method = "POST"; |
820 request_.url = GURL("http://www.example.org/"); | 846 request_.url = GURL("http://www.example.org/"); |
821 request_.upload_data_stream = &upload_data_stream; | 847 request_.upload_data_stream = &upload_data_stream; |
822 ASSERT_EQ(OK, request_.upload_data_stream->Init(CompletionCallback())); | 848 ASSERT_EQ(OK, request_.upload_data_stream->Init(CompletionCallback())); |
823 | 849 |
824 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 850 EXPECT_EQ(OK, |
825 callback_.callback())); | 851 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 852 net_log_.bound(), callback_.callback())); |
826 EXPECT_EQ(OK, | 853 EXPECT_EQ(OK, |
827 stream_->SendRequest(headers_, &response_, callback_.callback())); | 854 stream_->SendRequest(headers_, &response_, callback_.callback())); |
828 | 855 |
829 // Ack both packets in the request. | 856 // Ack both packets in the request. |
830 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 857 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
831 | 858 |
832 // Send the response headers (but not the body). | 859 // Send the response headers (but not the body). |
833 SetResponse("200 OK", std::string()); | 860 SetResponse("200 OK", std::string()); |
834 size_t spdy_response_headers_frame_length; | 861 size_t spdy_response_headers_frame_length; |
835 ProcessPacket(ConstructResponseHeadersPacket( | 862 ProcessPacket(ConstructResponseHeadersPacket( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 | 904 |
878 ChunkedUploadDataStream upload_data_stream(0); | 905 ChunkedUploadDataStream upload_data_stream(0); |
879 upload_data_stream.AppendData(kUploadData, chunk_size, false); | 906 upload_data_stream.AppendData(kUploadData, chunk_size, false); |
880 | 907 |
881 request_.method = "POST"; | 908 request_.method = "POST"; |
882 request_.url = GURL("http://www.example.org/"); | 909 request_.url = GURL("http://www.example.org/"); |
883 request_.upload_data_stream = &upload_data_stream; | 910 request_.upload_data_stream = &upload_data_stream; |
884 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 911 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
885 TestCompletionCallback().callback())); | 912 TestCompletionCallback().callback())); |
886 | 913 |
887 ASSERT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 914 ASSERT_EQ(OK, |
888 callback_.callback())); | 915 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 916 net_log_.bound(), callback_.callback())); |
889 ASSERT_EQ(ERR_IO_PENDING, | 917 ASSERT_EQ(ERR_IO_PENDING, |
890 stream_->SendRequest(headers_, &response_, callback_.callback())); | 918 stream_->SendRequest(headers_, &response_, callback_.callback())); |
891 | 919 |
892 upload_data_stream.AppendData(kUploadData, chunk_size, true); | 920 upload_data_stream.AppendData(kUploadData, chunk_size, true); |
893 EXPECT_EQ(OK, callback_.WaitForResult()); | 921 EXPECT_EQ(OK, callback_.WaitForResult()); |
894 | 922 |
895 // Ack both packets in the request. | 923 // Ack both packets in the request. |
896 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 924 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
897 | 925 |
898 // Send the response headers (but not the body). | 926 // Send the response headers (but not the body). |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 | 972 |
945 ChunkedUploadDataStream upload_data_stream(0); | 973 ChunkedUploadDataStream upload_data_stream(0); |
946 upload_data_stream.AppendData(kUploadData, chunk_size, false); | 974 upload_data_stream.AppendData(kUploadData, chunk_size, false); |
947 | 975 |
948 request_.method = "POST"; | 976 request_.method = "POST"; |
949 request_.url = GURL("http://www.example.org/"); | 977 request_.url = GURL("http://www.example.org/"); |
950 request_.upload_data_stream = &upload_data_stream; | 978 request_.upload_data_stream = &upload_data_stream; |
951 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 979 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
952 TestCompletionCallback().callback())); | 980 TestCompletionCallback().callback())); |
953 | 981 |
954 ASSERT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 982 ASSERT_EQ(OK, |
955 callback_.callback())); | 983 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 984 net_log_.bound(), callback_.callback())); |
956 ASSERT_EQ(ERR_IO_PENDING, | 985 ASSERT_EQ(ERR_IO_PENDING, |
957 stream_->SendRequest(headers_, &response_, callback_.callback())); | 986 stream_->SendRequest(headers_, &response_, callback_.callback())); |
958 | 987 |
959 upload_data_stream.AppendData(nullptr, 0, true); | 988 upload_data_stream.AppendData(nullptr, 0, true); |
960 EXPECT_EQ(OK, callback_.WaitForResult()); | 989 EXPECT_EQ(OK, callback_.WaitForResult()); |
961 | 990 |
962 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 991 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
963 | 992 |
964 // Send the response headers (but not the body). | 993 // Send the response headers (but not the body). |
965 SetResponse("200 OK", std::string()); | 994 SetResponse("200 OK", std::string()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 Initialize(); | 1035 Initialize(); |
1007 | 1036 |
1008 ChunkedUploadDataStream upload_data_stream(0); | 1037 ChunkedUploadDataStream upload_data_stream(0); |
1009 | 1038 |
1010 request_.method = "POST"; | 1039 request_.method = "POST"; |
1011 request_.url = GURL("http://www.example.org/"); | 1040 request_.url = GURL("http://www.example.org/"); |
1012 request_.upload_data_stream = &upload_data_stream; | 1041 request_.upload_data_stream = &upload_data_stream; |
1013 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1042 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1014 TestCompletionCallback().callback())); | 1043 TestCompletionCallback().callback())); |
1015 | 1044 |
1016 ASSERT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 1045 ASSERT_EQ(OK, |
1017 callback_.callback())); | 1046 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 1047 net_log_.bound(), callback_.callback())); |
1018 ASSERT_EQ(ERR_IO_PENDING, | 1048 ASSERT_EQ(ERR_IO_PENDING, |
1019 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1049 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1020 | 1050 |
1021 upload_data_stream.AppendData(nullptr, 0, true); | 1051 upload_data_stream.AppendData(nullptr, 0, true); |
1022 EXPECT_EQ(OK, callback_.WaitForResult()); | 1052 EXPECT_EQ(OK, callback_.WaitForResult()); |
1023 | 1053 |
1024 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 1054 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
1025 | 1055 |
1026 // Send the response headers (but not the body). | 1056 // Send the response headers (but not the body). |
1027 SetResponse("200 OK", std::string()); | 1057 SetResponse("200 OK", std::string()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 size_t spdy_request_headers_frame_length; | 1093 size_t spdy_request_headers_frame_length; |
1064 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, | 1094 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY, |
1065 &spdy_request_headers_frame_length)); | 1095 &spdy_request_headers_frame_length)); |
1066 AddWrite(ConstructAckAndRstStreamPacket(2)); | 1096 AddWrite(ConstructAckAndRstStreamPacket(2)); |
1067 use_closing_stream_ = true; | 1097 use_closing_stream_ = true; |
1068 Initialize(); | 1098 Initialize(); |
1069 | 1099 |
1070 request_.method = "GET"; | 1100 request_.method = "GET"; |
1071 request_.url = GURL("http://www.example.org/"); | 1101 request_.url = GURL("http://www.example.org/"); |
1072 | 1102 |
1073 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 1103 EXPECT_EQ(OK, |
1074 callback_.callback())); | 1104 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 1105 net_log_.bound(), callback_.callback())); |
1075 EXPECT_EQ(OK, | 1106 EXPECT_EQ(OK, |
1076 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1107 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1077 | 1108 |
1078 // Ack the request. | 1109 // Ack the request. |
1079 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 1110 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
1080 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 1111 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); |
1081 | 1112 |
1082 // Send the response with a body. | 1113 // Send the response with a body. |
1083 SetResponse("404 OK", "hello world!"); | 1114 SetResponse("404 OK", "hello world!"); |
1084 // In the course of processing this packet, the QuicHttpStream close itself. | 1115 // In the course of processing this packet, the QuicHttpStream close itself. |
(...skipping 16 matching lines...) Expand all Loading... |
1101 size_t spdy_request_headers_frame_length; | 1132 size_t spdy_request_headers_frame_length; |
1102 AddWrite(ConstructRequestHeadersPacket(1, kFin, MEDIUM, | 1133 AddWrite(ConstructRequestHeadersPacket(1, kFin, MEDIUM, |
1103 &spdy_request_headers_frame_length)); | 1134 &spdy_request_headers_frame_length)); |
1104 AddWrite(ConstructAckAndRstStreamPacket(2)); | 1135 AddWrite(ConstructAckAndRstStreamPacket(2)); |
1105 use_closing_stream_ = true; | 1136 use_closing_stream_ = true; |
1106 Initialize(); | 1137 Initialize(); |
1107 | 1138 |
1108 request_.method = "GET"; | 1139 request_.method = "GET"; |
1109 request_.url = GURL("http://www.example.org/"); | 1140 request_.url = GURL("http://www.example.org/"); |
1110 | 1141 |
1111 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_, | 1142 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_.bound(), |
1112 callback_.callback())); | 1143 callback_.callback())); |
1113 | 1144 |
1114 // Check that priority is highest. | 1145 // Check that priority is highest. |
1115 QuicChromiumClientStream* reliable_stream = | 1146 QuicChromiumClientStream* reliable_stream = |
1116 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); | 1147 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); |
1117 DCHECK(reliable_stream); | 1148 DCHECK(reliable_stream); |
1118 DCHECK_EQ(kV3HighestPriority, reliable_stream->priority()); | 1149 DCHECK_EQ(kV3HighestPriority, reliable_stream->priority()); |
1119 | 1150 |
1120 EXPECT_EQ(OK, | 1151 EXPECT_EQ(OK, |
1121 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1152 stream_->SendRequest(headers_, &response_, callback_.callback())); |
(...skipping 28 matching lines...) Expand all Loading... |
1150 SetRequest("GET", "/", MEDIUM); | 1181 SetRequest("GET", "/", MEDIUM); |
1151 use_closing_stream_ = true; | 1182 use_closing_stream_ = true; |
1152 | 1183 |
1153 AddWrite(ConstructRstStreamPacket(1)); | 1184 AddWrite(ConstructRstStreamPacket(1)); |
1154 | 1185 |
1155 Initialize(); | 1186 Initialize(); |
1156 | 1187 |
1157 request_.method = "GET"; | 1188 request_.method = "GET"; |
1158 request_.url = GURL("http://www.example.org/"); | 1189 request_.url = GURL("http://www.example.org/"); |
1159 | 1190 |
1160 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_, | 1191 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_.bound(), |
1161 callback_.callback())); | 1192 callback_.callback())); |
1162 | 1193 |
1163 // Check that priority is highest. | 1194 // Check that priority is highest. |
1164 QuicChromiumClientStream* reliable_stream = | 1195 QuicChromiumClientStream* reliable_stream = |
1165 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); | 1196 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); |
1166 DCHECK(reliable_stream); | 1197 DCHECK(reliable_stream); |
1167 QuicChromiumClientStream::Delegate* delegate = reliable_stream->GetDelegate(); | 1198 QuicChromiumClientStream::Delegate* delegate = reliable_stream->GetDelegate(); |
1168 DCHECK(delegate); | 1199 DCHECK(delegate); |
1169 DCHECK_EQ(kV3HighestPriority, reliable_stream->priority()); | 1200 DCHECK_EQ(kV3HighestPriority, reliable_stream->priority()); |
1170 | 1201 |
(...skipping 13 matching lines...) Expand all Loading... |
1184 Initialize(); | 1215 Initialize(); |
1185 | 1216 |
1186 ChunkedUploadDataStream upload_data_stream(0); | 1217 ChunkedUploadDataStream upload_data_stream(0); |
1187 | 1218 |
1188 request_.method = "POST"; | 1219 request_.method = "POST"; |
1189 request_.url = GURL("http://www.example.org/"); | 1220 request_.url = GURL("http://www.example.org/"); |
1190 request_.upload_data_stream = &upload_data_stream; | 1221 request_.upload_data_stream = &upload_data_stream; |
1191 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1222 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1192 TestCompletionCallback().callback())); | 1223 TestCompletionCallback().callback())); |
1193 | 1224 |
1194 ASSERT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 1225 ASSERT_EQ(OK, |
1195 callback_.callback())); | 1226 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 1227 net_log_.bound(), callback_.callback())); |
1196 ASSERT_EQ(ERR_QUIC_PROTOCOL_ERROR, | 1228 ASSERT_EQ(ERR_QUIC_PROTOCOL_ERROR, |
1197 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1229 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1198 } | 1230 } |
1199 | 1231 |
1200 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendBodyComplete) { | 1232 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendBodyComplete) { |
1201 SetRequest("POST", "/", DEFAULT_PRIORITY); | 1233 SetRequest("POST", "/", DEFAULT_PRIORITY); |
1202 size_t spdy_request_headers_frame_length; | 1234 size_t spdy_request_headers_frame_length; |
1203 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY, | 1235 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY, |
1204 &spdy_request_headers_frame_length)); | 1236 &spdy_request_headers_frame_length)); |
1205 AddWrite(SYNCHRONOUS, ERR_FAILED); | 1237 AddWrite(SYNCHRONOUS, ERR_FAILED); |
1206 Initialize(); | 1238 Initialize(); |
1207 | 1239 |
1208 ChunkedUploadDataStream upload_data_stream(0); | 1240 ChunkedUploadDataStream upload_data_stream(0); |
1209 size_t chunk_size = strlen(kUploadData); | 1241 size_t chunk_size = strlen(kUploadData); |
1210 upload_data_stream.AppendData(kUploadData, chunk_size, false); | 1242 upload_data_stream.AppendData(kUploadData, chunk_size, false); |
1211 | 1243 |
1212 request_.method = "POST"; | 1244 request_.method = "POST"; |
1213 request_.url = GURL("http://www.example.org/"); | 1245 request_.url = GURL("http://www.example.org/"); |
1214 request_.upload_data_stream = &upload_data_stream; | 1246 request_.upload_data_stream = &upload_data_stream; |
1215 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1247 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1216 TestCompletionCallback().callback())); | 1248 TestCompletionCallback().callback())); |
1217 | 1249 |
1218 ASSERT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 1250 ASSERT_EQ(OK, |
1219 callback_.callback())); | 1251 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 1252 net_log_.bound(), callback_.callback())); |
1220 ASSERT_EQ(ERR_QUIC_PROTOCOL_ERROR, | 1253 ASSERT_EQ(ERR_QUIC_PROTOCOL_ERROR, |
1221 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1254 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1222 } | 1255 } |
1223 | 1256 |
1224 TEST_P(QuicHttpStreamTest, ServerPushGetRequest) { | 1257 TEST_P(QuicHttpStreamTest, ServerPushGetRequest) { |
1225 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1258 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1226 Initialize(); | 1259 Initialize(); |
1227 | 1260 |
1228 // Initialize the first stream, for receiving the promise on. | 1261 // Initialize the first stream, for receiving the promise on. |
1229 request_.method = "GET"; | 1262 request_.method = "GET"; |
1230 request_.url = GURL("http://www.example.org/"); | 1263 request_.url = GURL("http://www.example.org/"); |
1231 | 1264 |
1232 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 1265 EXPECT_EQ(OK, |
1233 callback_.callback())); | 1266 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 1267 net_log_.bound(), callback_.callback())); |
1234 | 1268 |
1235 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1269 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1236 // packet, but does it matter? | 1270 // packet, but does it matter? |
1237 ReceivePromise(promise_id_); | 1271 ReceivePromise(promise_id_); |
1238 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 1272 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
1239 | 1273 |
1240 request_.url = GURL(promise_url_); | 1274 request_.url = GURL(promise_url_); |
1241 | 1275 |
1242 // Make the second stream that will exercise the first step of the | 1276 // Make the second stream that will exercise the first step of the |
1243 // server push rendezvous mechanism. | 1277 // server push rendezvous mechanism. |
1244 EXPECT_EQ(OK, | 1278 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1245 promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1279 net_log_.bound(), |
1246 net_log_, callback_.callback())); | 1280 callback_.callback())); |
1247 | 1281 |
1248 // Receive the promised response headers. | 1282 // Receive the promised response headers. |
1249 response_headers_ = promised_response_; | 1283 response_headers_ = promised_response_; |
1250 size_t spdy_response_headers_frame_length; | 1284 size_t spdy_response_headers_frame_length; |
1251 ProcessPacket(InnerConstructResponseHeadersPacket( | 1285 ProcessPacket(InnerConstructResponseHeadersPacket( |
1252 1, promise_id_, false, &spdy_response_headers_frame_length)); | 1286 1, promise_id_, false, &spdy_response_headers_frame_length)); |
1253 | 1287 |
1254 // Receive the promised response body. | 1288 // Receive the promised response body. |
1255 const char kResponseBody[] = "Hello world!"; | 1289 const char kResponseBody[] = "Hello world!"; |
1256 ProcessPacket( | 1290 ProcessPacket( |
(...skipping 29 matching lines...) Expand all Loading... |
1286 } | 1320 } |
1287 | 1321 |
1288 TEST_P(QuicHttpStreamTest, ServerPushGetRequestSlowResponse) { | 1322 TEST_P(QuicHttpStreamTest, ServerPushGetRequestSlowResponse) { |
1289 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1323 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1290 Initialize(); | 1324 Initialize(); |
1291 | 1325 |
1292 // Initialize the first stream, for receiving the promise on. | 1326 // Initialize the first stream, for receiving the promise on. |
1293 request_.method = "GET"; | 1327 request_.method = "GET"; |
1294 request_.url = GURL("http://www.example.org/"); | 1328 request_.url = GURL("http://www.example.org/"); |
1295 | 1329 |
1296 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 1330 EXPECT_EQ(OK, |
1297 callback_.callback())); | 1331 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 1332 net_log_.bound(), callback_.callback())); |
1298 | 1333 |
1299 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1334 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1300 // packet, but does it matter? | 1335 // packet, but does it matter? |
1301 ReceivePromise(promise_id_); | 1336 ReceivePromise(promise_id_); |
1302 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 1337 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
1303 | 1338 |
1304 request_.url = GURL(promise_url_); | 1339 request_.url = GURL(promise_url_); |
1305 | 1340 |
1306 // Make the second stream that will exercise the first step of the | 1341 // Make the second stream that will exercise the first step of the |
1307 // server push rendezvous mechanism. | 1342 // server push rendezvous mechanism. |
1308 EXPECT_EQ(OK, | 1343 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1309 promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1344 net_log_.bound(), |
1310 net_log_, callback_.callback())); | 1345 callback_.callback())); |
1311 | 1346 |
1312 // Now sending a matching request will rendezvous with the promised | 1347 // Now sending a matching request will rendezvous with the promised |
1313 // stream, but pending secondary validation. | 1348 // stream, but pending secondary validation. |
1314 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( | 1349 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( |
1315 headers_, &response_, callback_.callback())); | 1350 headers_, &response_, callback_.callback())); |
1316 | 1351 |
1317 // Receive the promised response headers. | 1352 // Receive the promised response headers. |
1318 response_headers_ = promised_response_; | 1353 response_headers_ = promised_response_; |
1319 size_t spdy_response_headers_frame_length; | 1354 size_t spdy_response_headers_frame_length; |
1320 ProcessPacket(InnerConstructResponseHeadersPacket( | 1355 ProcessPacket(InnerConstructResponseHeadersPacket( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 } | 1392 } |
1358 | 1393 |
1359 TEST_P(QuicHttpStreamTest, ServerPushCrossOriginOK) { | 1394 TEST_P(QuicHttpStreamTest, ServerPushCrossOriginOK) { |
1360 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1395 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1361 Initialize(); | 1396 Initialize(); |
1362 | 1397 |
1363 // Initialize the first stream, for receiving the promise on. | 1398 // Initialize the first stream, for receiving the promise on. |
1364 request_.method = "GET"; | 1399 request_.method = "GET"; |
1365 request_.url = GURL("http://www.example.org/"); | 1400 request_.url = GURL("http://www.example.org/"); |
1366 | 1401 |
1367 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 1402 EXPECT_EQ(OK, |
1368 callback_.callback())); | 1403 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 1404 net_log_.bound(), callback_.callback())); |
1369 | 1405 |
1370 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1406 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1371 // packet, but does it matter? | 1407 // packet, but does it matter? |
1372 | 1408 |
1373 push_promise_[":authority"] = "mail.example.org"; | 1409 push_promise_[":authority"] = "mail.example.org"; |
1374 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); | 1410 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); |
1375 serialized_push_promise_ = | 1411 serialized_push_promise_ = |
1376 SpdyUtils::SerializeUncompressedHeaders(push_promise_); | 1412 SpdyUtils::SerializeUncompressedHeaders(push_promise_); |
1377 | 1413 |
1378 ReceivePromise(promise_id_); | 1414 ReceivePromise(promise_id_); |
1379 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 1415 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
1380 | 1416 |
1381 request_.url = GURL(promise_url_); | 1417 request_.url = GURL(promise_url_); |
1382 | 1418 |
1383 // Make the second stream that will exercise the first step of the | 1419 // Make the second stream that will exercise the first step of the |
1384 // server push rendezvous mechanism. | 1420 // server push rendezvous mechanism. |
1385 EXPECT_EQ(OK, | 1421 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1386 promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1422 net_log_.bound(), |
1387 net_log_, callback_.callback())); | 1423 callback_.callback())); |
1388 | 1424 |
1389 // Receive the promised response headers. | 1425 // Receive the promised response headers. |
1390 response_headers_ = promised_response_; | 1426 response_headers_ = promised_response_; |
1391 size_t spdy_response_headers_frame_length; | 1427 size_t spdy_response_headers_frame_length; |
1392 ProcessPacket(InnerConstructResponseHeadersPacket( | 1428 ProcessPacket(InnerConstructResponseHeadersPacket( |
1393 1, promise_id_, false, &spdy_response_headers_frame_length)); | 1429 1, promise_id_, false, &spdy_response_headers_frame_length)); |
1394 | 1430 |
1395 // Receive the promised response body. | 1431 // Receive the promised response body. |
1396 const char kResponseBody[] = "Hello world!"; | 1432 const char kResponseBody[] = "Hello world!"; |
1397 ProcessPacket( | 1433 ProcessPacket( |
(...skipping 29 matching lines...) Expand all Loading... |
1427 } | 1463 } |
1428 | 1464 |
1429 TEST_P(QuicHttpStreamTest, ServerPushCrossOriginFail) { | 1465 TEST_P(QuicHttpStreamTest, ServerPushCrossOriginFail) { |
1430 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1466 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1431 Initialize(); | 1467 Initialize(); |
1432 | 1468 |
1433 // Initialize the first stream, for receiving the promise on. | 1469 // Initialize the first stream, for receiving the promise on. |
1434 request_.method = "GET"; | 1470 request_.method = "GET"; |
1435 request_.url = GURL("http://www.example.org/"); | 1471 request_.url = GURL("http://www.example.org/"); |
1436 | 1472 |
1437 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 1473 EXPECT_EQ(OK, |
1438 callback_.callback())); | 1474 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 1475 net_log_.bound(), callback_.callback())); |
1439 | 1476 |
1440 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1477 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1441 // packet, but does it matter? | 1478 // packet, but does it matter? |
1442 push_promise_[":authority"] = "www.notexample.org"; | 1479 push_promise_[":authority"] = "www.notexample.org"; |
1443 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); | 1480 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); |
1444 serialized_push_promise_ = | 1481 serialized_push_promise_ = |
1445 SpdyUtils::SerializeUncompressedHeaders(push_promise_); | 1482 SpdyUtils::SerializeUncompressedHeaders(push_promise_); |
1446 | 1483 |
1447 ReceivePromise(promise_id_); | 1484 ReceivePromise(promise_id_); |
1448 // The promise will have been rejected because the cert doesn't | 1485 // The promise will have been rejected because the cert doesn't |
1449 // match. | 1486 // match. |
1450 EXPECT_EQ(session_->GetPromisedByUrl(promise_url_), nullptr); | 1487 EXPECT_EQ(session_->GetPromisedByUrl(promise_url_), nullptr); |
1451 } | 1488 } |
1452 | 1489 |
1453 TEST_P(QuicHttpStreamTest, ServerPushVaryCheckOK) { | 1490 TEST_P(QuicHttpStreamTest, ServerPushVaryCheckOK) { |
1454 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1491 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1455 Initialize(); | 1492 Initialize(); |
1456 | 1493 |
1457 // Initialize the first stream, for receiving the promise on. | 1494 // Initialize the first stream, for receiving the promise on. |
1458 request_.method = "GET"; | 1495 request_.method = "GET"; |
1459 request_.url = GURL("http://www.example.org/"); | 1496 request_.url = GURL("http://www.example.org/"); |
1460 | 1497 |
1461 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 1498 EXPECT_EQ(OK, |
1462 callback_.callback())); | 1499 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 1500 net_log_.bound(), callback_.callback())); |
1463 | 1501 |
1464 push_promise_["accept-encoding"] = "gzip"; | 1502 push_promise_["accept-encoding"] = "gzip"; |
1465 serialized_push_promise_ = | 1503 serialized_push_promise_ = |
1466 SpdyUtils::SerializeUncompressedHeaders(push_promise_); | 1504 SpdyUtils::SerializeUncompressedHeaders(push_promise_); |
1467 | 1505 |
1468 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1506 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1469 // packet, but does it matter? | 1507 // packet, but does it matter? |
1470 ReceivePromise(promise_id_); | 1508 ReceivePromise(promise_id_); |
1471 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 1509 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
1472 | 1510 |
1473 request_.url = GURL(promise_url_); | 1511 request_.url = GURL(promise_url_); |
1474 | 1512 |
1475 // Make the second stream that will exercise the first step of the | 1513 // Make the second stream that will exercise the first step of the |
1476 // server push rendezvous mechanism. | 1514 // server push rendezvous mechanism. |
1477 EXPECT_EQ(OK, | 1515 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1478 promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1516 net_log_.bound(), |
1479 net_log_, callback_.callback())); | 1517 callback_.callback())); |
1480 | 1518 |
1481 headers_.SetHeader("accept-encoding", "gzip"); | 1519 headers_.SetHeader("accept-encoding", "gzip"); |
1482 | 1520 |
1483 // Now sending a matching request will rendezvous with the promised | 1521 // Now sending a matching request will rendezvous with the promised |
1484 // stream, but pending secondary validation. | 1522 // stream, but pending secondary validation. |
1485 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( | 1523 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( |
1486 headers_, &response_, callback_.callback())); | 1524 headers_, &response_, callback_.callback())); |
1487 | 1525 |
1488 // Receive the promised response headers. | 1526 // Receive the promised response headers. |
1489 promised_response_["vary"] = "accept-encoding"; | 1527 promised_response_["vary"] = "accept-encoding"; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 2, stream_id_ + 2, !kIncludeVersion, kFin, DEFAULT_PRIORITY, | 1578 2, stream_id_ + 2, !kIncludeVersion, kFin, DEFAULT_PRIORITY, |
1541 &spdy_request_header_frame_length)); | 1579 &spdy_request_header_frame_length)); |
1542 AddWrite(ConstructAckPacket(3, 3, 1)); | 1580 AddWrite(ConstructAckPacket(3, 3, 1)); |
1543 AddWrite(ConstructRstStreamCancelledPacket(4)); | 1581 AddWrite(ConstructRstStreamCancelledPacket(4)); |
1544 Initialize(); | 1582 Initialize(); |
1545 | 1583 |
1546 // Initialize the first stream, for receiving the promise on. | 1584 // Initialize the first stream, for receiving the promise on. |
1547 request_.method = "GET"; | 1585 request_.method = "GET"; |
1548 request_.url = GURL("http://www.example.org/"); | 1586 request_.url = GURL("http://www.example.org/"); |
1549 | 1587 |
1550 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_, | 1588 EXPECT_EQ(OK, |
1551 callback_.callback())); | 1589 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 1590 net_log_.bound(), callback_.callback())); |
1552 | 1591 |
1553 push_promise_["accept-encoding"] = "gzip"; | 1592 push_promise_["accept-encoding"] = "gzip"; |
1554 serialized_push_promise_ = | 1593 serialized_push_promise_ = |
1555 SpdyUtils::SerializeUncompressedHeaders(push_promise_); | 1594 SpdyUtils::SerializeUncompressedHeaders(push_promise_); |
1556 | 1595 |
1557 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1596 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1558 // packet, but does it matter? | 1597 // packet, but does it matter? |
1559 ReceivePromise(promise_id_); | 1598 ReceivePromise(promise_id_); |
1560 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 1599 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
1561 | 1600 |
1562 request_.url = GURL(promise_url_); | 1601 request_.url = GURL(promise_url_); |
1563 | 1602 |
1564 // Make the second stream that will exercise the first step of the | 1603 // Make the second stream that will exercise the first step of the |
1565 // server push rendezvous mechanism. | 1604 // server push rendezvous mechanism. |
1566 EXPECT_EQ(OK, | 1605 EXPECT_EQ(OK, promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1567 promised_stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1606 net_log_.bound(), |
1568 net_log_, callback_.callback())); | 1607 callback_.callback())); |
1569 | 1608 |
1570 headers_.SetHeader("accept-encoding", "sdch"); | 1609 headers_.SetHeader("accept-encoding", "sdch"); |
1571 | 1610 |
1572 // Now sending a matching request will rendezvous with the promised | 1611 // Now sending a matching request will rendezvous with the promised |
1573 // stream, but pending secondary validation. | 1612 // stream, but pending secondary validation. |
1574 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( | 1613 EXPECT_EQ(ERR_IO_PENDING, promised_stream_->SendRequest( |
1575 headers_, &response_, callback_.callback())); | 1614 headers_, &response_, callback_.callback())); |
1576 | 1615 |
1577 // Receive the promised response headers. | 1616 // Receive the promised response headers. |
1578 promised_response_["vary"] = "accept-encoding"; | 1617 promised_response_["vary"] = "accept-encoding"; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | 1675 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
1637 // headers and payload. | 1676 // headers and payload. |
1638 EXPECT_EQ(static_cast<int64_t>(spdy_request_header_frame_length), | 1677 EXPECT_EQ(static_cast<int64_t>(spdy_request_header_frame_length), |
1639 promised_stream_->GetTotalSentBytes()); | 1678 promised_stream_->GetTotalSentBytes()); |
1640 EXPECT_EQ(static_cast<int64_t>(spdy_response_header_frame_length), | 1679 EXPECT_EQ(static_cast<int64_t>(spdy_response_header_frame_length), |
1641 promised_stream_->GetTotalReceivedBytes()); | 1680 promised_stream_->GetTotalReceivedBytes()); |
1642 } | 1681 } |
1643 | 1682 |
1644 } // namespace test | 1683 } // namespace test |
1645 } // namespace net | 1684 } // namespace net |
OLD | NEW |