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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 stream_->ReadResponseHeaders(callback_.callback())); | 344 stream_->ReadResponseHeaders(callback_.callback())); |
345 | 345 |
346 // Send the response without a body. | 346 // Send the response without a body. |
347 SetResponseString("404 Not Found", std::string()); | 347 SetResponseString("404 Not Found", std::string()); |
348 scoped_ptr<QuicEncryptedPacket> resp( | 348 scoped_ptr<QuicEncryptedPacket> resp( |
349 ConstructDataPacket(2, false, kFin, 0, response_data_)); | 349 ConstructDataPacket(2, false, kFin, 0, response_data_)); |
350 ProcessPacket(*resp); | 350 ProcessPacket(*resp); |
351 | 351 |
352 // Now that the headers have been processed, the callback will return. | 352 // Now that the headers have been processed, the callback will return. |
353 EXPECT_EQ(OK, callback_.WaitForResult()); | 353 EXPECT_EQ(OK, callback_.WaitForResult()); |
354 ASSERT_TRUE(response_.headers.get() != NULL); | 354 ASSERT_TRUE(response_.headers.get() != NULL); |
Ryan Hamilton
2013/06/05 16:41:23
I think you can simply say:
ASSERT_TRUE(response_
ramant (doing other things)
2013/06/05 16:55:39
Done.
| |
355 EXPECT_EQ(404, response_.headers->response_code()); | 355 EXPECT_EQ(404, response_.headers->response_code()); |
356 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 356 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
357 | 357 |
358 // There is no body, so this should return immediately. | 358 // There is no body, so this should return immediately. |
359 EXPECT_EQ(0, stream_->ReadResponseBody(read_buffer_.get(), | 359 EXPECT_EQ(0, stream_->ReadResponseBody(read_buffer_.get(), |
360 read_buffer_->size(), | 360 read_buffer_->size(), |
361 callback_.callback())); | 361 callback_.callback())); |
362 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 362 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
363 EXPECT_TRUE(AtEof()); | 363 EXPECT_TRUE(AtEof()); |
364 } | 364 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 521 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
522 callback_.callback())); | 522 callback_.callback())); |
523 | 523 |
524 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 524 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
525 EXPECT_TRUE(AtEof()); | 525 EXPECT_TRUE(AtEof()); |
526 } | 526 } |
527 | 527 |
528 TEST_F(QuicHttpStreamTest, DestroyedEarly) { | 528 TEST_F(QuicHttpStreamTest, DestroyedEarly) { |
529 SetRequestString("GET", "/"); | 529 SetRequestString("GET", "/"); |
530 AddWrite(SYNCHRONOUS, ConstructDataPacket(1, true, kFin, 0, request_data_)); | 530 AddWrite(SYNCHRONOUS, ConstructDataPacket(1, true, kFin, 0, request_data_)); |
531 AddWrite(SYNCHRONOUS, ConstructRstPacket(2, 3)); | 531 AddWrite(SYNCHRONOUS, ConstructAckPacket(2, 2, 1)); |
532 AddWrite(SYNCHRONOUS, ConstructAckPacket(3, 2, 1)); | |
533 use_closing_stream_ = true; | 532 use_closing_stream_ = true; |
534 Initialize(); | 533 Initialize(); |
535 | 534 |
536 request_.method = "GET"; | 535 request_.method = "GET"; |
537 request_.url = GURL("http://www.google.com/"); | 536 request_.url = GURL("http://www.google.com/"); |
538 | 537 |
539 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 538 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
540 net_log_, callback_.callback())); | 539 net_log_, callback_.callback())); |
541 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, | 540 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, |
542 callback_.callback())); | 541 callback_.callback())); |
(...skipping 12 matching lines...) Expand all Loading... | |
555 | 554 |
556 // In the course of processing this packet, the QuicHttpStream close itself. | 555 // In the course of processing this packet, the QuicHttpStream close itself. |
557 ProcessPacket(*resp); | 556 ProcessPacket(*resp); |
558 | 557 |
559 EXPECT_TRUE(AtEof()); | 558 EXPECT_TRUE(AtEof()); |
560 } | 559 } |
561 | 560 |
562 } // namespace test | 561 } // namespace test |
563 | 562 |
564 } // namespace net | 563 } // namespace net |
OLD | NEW |