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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 EXPECT_EQ(&response_, stream_->GetResponseInfo()); | 341 EXPECT_EQ(&response_, stream_->GetResponseInfo()); |
342 | 342 |
343 // Ack the request. | 343 // Ack the request. |
344 scoped_ptr<QuicEncryptedPacket> ack(ConstructAckPacket(1, 0, 0)); | 344 scoped_ptr<QuicEncryptedPacket> ack(ConstructAckPacket(1, 0, 0)); |
345 ProcessPacket(*ack); | 345 ProcessPacket(*ack); |
346 | 346 |
347 EXPECT_EQ(ERR_IO_PENDING, | 347 EXPECT_EQ(ERR_IO_PENDING, |
348 stream_->ReadResponseHeaders(callback_.callback())); | 348 stream_->ReadResponseHeaders(callback_.callback())); |
349 | 349 |
350 // Send the response without a body. | 350 // Send the response without a body. |
351 SetResponseString("404 Not Found", ""); | 351 SetResponseString("404 Not Found", std::string()); |
352 scoped_ptr<QuicEncryptedPacket> resp( | 352 scoped_ptr<QuicEncryptedPacket> resp( |
353 ConstructDataPacket(2, false, kFin, 0, response_data_)); | 353 ConstructDataPacket(2, false, kFin, 0, response_data_)); |
354 ProcessPacket(*resp); | 354 ProcessPacket(*resp); |
355 | 355 |
356 // Now that the headers have been processed, the callback will return. | 356 // Now that the headers have been processed, the callback will return. |
357 EXPECT_EQ(OK, callback_.WaitForResult()); | 357 EXPECT_EQ(OK, callback_.WaitForResult()); |
358 ASSERT_TRUE(response_.headers != NULL); | 358 ASSERT_TRUE(response_.headers != NULL); |
359 EXPECT_EQ(404, response_.headers->response_code()); | 359 EXPECT_EQ(404, response_.headers->response_code()); |
360 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 360 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
361 | 361 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 net_log_, callback_.callback())); | 433 net_log_, callback_.callback())); |
434 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, | 434 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, |
435 callback_.callback())); | 435 callback_.callback())); |
436 EXPECT_EQ(&response_, stream_->GetResponseInfo()); | 436 EXPECT_EQ(&response_, stream_->GetResponseInfo()); |
437 | 437 |
438 // Ack both packets in the request. | 438 // Ack both packets in the request. |
439 scoped_ptr<QuicEncryptedPacket> ack(ConstructAckPacket(1, 0, 0)); | 439 scoped_ptr<QuicEncryptedPacket> ack(ConstructAckPacket(1, 0, 0)); |
440 ProcessPacket(*ack); | 440 ProcessPacket(*ack); |
441 | 441 |
442 // Send the response headers (but not the body). | 442 // Send the response headers (but not the body). |
443 SetResponseString("200 OK", ""); | 443 SetResponseString("200 OK", std::string()); |
444 scoped_ptr<QuicEncryptedPacket> resp( | 444 scoped_ptr<QuicEncryptedPacket> resp( |
445 ConstructDataPacket(2, false, !kFin, 0, response_data_)); | 445 ConstructDataPacket(2, false, !kFin, 0, response_data_)); |
446 ProcessPacket(*resp); | 446 ProcessPacket(*resp); |
447 | 447 |
448 // Since the headers have already arrived, this should return immediately. | 448 // Since the headers have already arrived, this should return immediately. |
449 EXPECT_EQ(OK, stream_->ReadResponseHeaders(callback_.callback())); | 449 EXPECT_EQ(OK, stream_->ReadResponseHeaders(callback_.callback())); |
450 ASSERT_TRUE(response_.headers != NULL); | 450 ASSERT_TRUE(response_.headers != NULL); |
451 EXPECT_EQ(200, response_.headers->response_code()); | 451 EXPECT_EQ(200, response_.headers->response_code()); |
452 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 452 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
453 | 453 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 callback_.callback())); | 495 callback_.callback())); |
496 EXPECT_EQ(&response_, stream_->GetResponseInfo()); | 496 EXPECT_EQ(&response_, stream_->GetResponseInfo()); |
497 | 497 |
498 upload_data_stream.AppendChunk(kUploadData, chunk_size, true); | 498 upload_data_stream.AppendChunk(kUploadData, chunk_size, true); |
499 | 499 |
500 // Ack both packets in the request. | 500 // Ack both packets in the request. |
501 scoped_ptr<QuicEncryptedPacket> ack(ConstructAckPacket(1, 0, 0)); | 501 scoped_ptr<QuicEncryptedPacket> ack(ConstructAckPacket(1, 0, 0)); |
502 ProcessPacket(*ack); | 502 ProcessPacket(*ack); |
503 | 503 |
504 // Send the response headers (but not the body). | 504 // Send the response headers (but not the body). |
505 SetResponseString("200 OK", ""); | 505 SetResponseString("200 OK", std::string()); |
506 scoped_ptr<QuicEncryptedPacket> resp( | 506 scoped_ptr<QuicEncryptedPacket> resp( |
507 ConstructDataPacket(2, false, !kFin, 0, response_data_)); | 507 ConstructDataPacket(2, false, !kFin, 0, response_data_)); |
508 ProcessPacket(*resp); | 508 ProcessPacket(*resp); |
509 | 509 |
510 // Since the headers have already arrived, this should return immediately. | 510 // Since the headers have already arrived, this should return immediately. |
511 ASSERT_EQ(OK, stream_->ReadResponseHeaders(callback_.callback())); | 511 ASSERT_EQ(OK, stream_->ReadResponseHeaders(callback_.callback())); |
512 ASSERT_TRUE(response_.headers != NULL); | 512 ASSERT_TRUE(response_.headers != NULL); |
513 EXPECT_EQ(200, response_.headers->response_code()); | 513 EXPECT_EQ(200, response_.headers->response_code()); |
514 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 514 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
515 | 515 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 | 560 |
561 // In the course of processing this packet, the QuicHttpStream close itself. | 561 // In the course of processing this packet, the QuicHttpStream close itself. |
562 ProcessPacket(*resp); | 562 ProcessPacket(*resp); |
563 | 563 |
564 EXPECT_TRUE(AtEof()); | 564 EXPECT_TRUE(AtEof()); |
565 } | 565 } |
566 | 566 |
567 } // namespace test | 567 } // namespace test |
568 | 568 |
569 } // namespace net | 569 } // namespace net |
OLD | NEW |