| 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> |
| 8 |
| 7 #include <vector> | 9 #include <vector> |
| 8 | 10 |
| 9 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 10 #include "net/base/chunked_upload_data_stream.h" | 12 #include "net/base/chunked_upload_data_stream.h" |
| 11 #include "net/base/elements_upload_data_stream.h" | 13 #include "net/base/elements_upload_data_stream.h" |
| 12 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 13 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
| 14 #include "net/base/upload_bytes_element_reader.h" | 16 #include "net/base/upload_bytes_element_reader.h" |
| 15 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
| 16 #include "net/http/transport_security_state.h" | 18 #include "net/http/transport_security_state.h" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 376 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
| 375 EXPECT_FALSE(response_.response_time.is_null()); | 377 EXPECT_FALSE(response_.response_time.is_null()); |
| 376 EXPECT_FALSE(response_.request_time.is_null()); | 378 EXPECT_FALSE(response_.request_time.is_null()); |
| 377 | 379 |
| 378 // There is no body, so this should return immediately. | 380 // There is no body, so this should return immediately. |
| 379 EXPECT_EQ(0, stream_->ReadResponseBody(read_buffer_.get(), | 381 EXPECT_EQ(0, stream_->ReadResponseBody(read_buffer_.get(), |
| 380 read_buffer_->size(), | 382 read_buffer_->size(), |
| 381 callback_.callback())); | 383 callback_.callback())); |
| 382 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 384 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 383 EXPECT_TRUE(AtEof()); | 385 EXPECT_TRUE(AtEof()); |
| 386 |
| 387 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 388 // payload. |
| 389 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
| 390 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
| 384 } | 391 } |
| 385 | 392 |
| 386 // Regression test for http://crbug.com/288128 | 393 // Regression test for http://crbug.com/288128 |
| 387 TEST_P(QuicHttpStreamTest, GetRequestLargeResponse) { | 394 TEST_P(QuicHttpStreamTest, GetRequestLargeResponse) { |
| 388 SetRequest("GET", "/", DEFAULT_PRIORITY); | 395 SetRequest("GET", "/", DEFAULT_PRIORITY); |
| 389 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); | 396 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); |
| 390 Initialize(); | 397 Initialize(); |
| 391 | 398 |
| 392 request_.method = "GET"; | 399 request_.method = "GET"; |
| 393 request_.url = GURL("http://www.google.com/"); | 400 request_.url = GURL("http://www.google.com/"); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 417 ASSERT_TRUE(response_.headers.get()); | 424 ASSERT_TRUE(response_.headers.get()); |
| 418 EXPECT_EQ(200, response_.headers->response_code()); | 425 EXPECT_EQ(200, response_.headers->response_code()); |
| 419 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 426 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
| 420 | 427 |
| 421 // There is no body, so this should return immediately. | 428 // There is no body, so this should return immediately. |
| 422 EXPECT_EQ(0, stream_->ReadResponseBody(read_buffer_.get(), | 429 EXPECT_EQ(0, stream_->ReadResponseBody(read_buffer_.get(), |
| 423 read_buffer_->size(), | 430 read_buffer_->size(), |
| 424 callback_.callback())); | 431 callback_.callback())); |
| 425 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 432 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 426 EXPECT_TRUE(AtEof()); | 433 EXPECT_TRUE(AtEof()); |
| 434 |
| 435 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 436 // payload. |
| 437 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
| 438 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
| 427 } | 439 } |
| 428 | 440 |
| 429 // Regression test for http://crbug.com/409101 | 441 // Regression test for http://crbug.com/409101 |
| 430 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendRequest) { | 442 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendRequest) { |
| 431 SetRequest("GET", "/", DEFAULT_PRIORITY); | 443 SetRequest("GET", "/", DEFAULT_PRIORITY); |
| 432 Initialize(); | 444 Initialize(); |
| 433 | 445 |
| 434 request_.method = "GET"; | 446 request_.method = "GET"; |
| 435 request_.url = GURL("http://www.google.com/"); | 447 request_.url = GURL("http://www.google.com/"); |
| 436 | 448 |
| 437 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 449 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 438 net_log_, callback_.callback())); | 450 net_log_, callback_.callback())); |
| 439 | 451 |
| 440 session_->connection()->CloseConnection(QUIC_NO_ERROR, true); | 452 session_->connection()->CloseConnection(QUIC_NO_ERROR, true); |
| 441 | 453 |
| 442 EXPECT_EQ(ERR_CONNECTION_CLOSED, | 454 EXPECT_EQ(ERR_CONNECTION_CLOSED, |
| 443 stream_->SendRequest(headers_, &response_, | 455 stream_->SendRequest(headers_, &response_, |
| 444 callback_.callback())); | 456 callback_.callback())); |
| 457 |
| 458 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
| 459 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
| 445 } | 460 } |
| 446 | 461 |
| 447 // Regression test for http://crbug.com/409871 | 462 // Regression test for http://crbug.com/409871 |
| 448 TEST_P(QuicHttpStreamTest, SessionClosedBeforeReadResponseHeaders) { | 463 TEST_P(QuicHttpStreamTest, SessionClosedBeforeReadResponseHeaders) { |
| 449 SetRequest("GET", "/", DEFAULT_PRIORITY); | 464 SetRequest("GET", "/", DEFAULT_PRIORITY); |
| 450 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); | 465 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); |
| 451 Initialize(); | 466 Initialize(); |
| 452 | 467 |
| 453 request_.method = "GET"; | 468 request_.method = "GET"; |
| 454 request_.url = GURL("http://www.google.com/"); | 469 request_.url = GURL("http://www.google.com/"); |
| 455 | 470 |
| 456 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 471 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 457 net_log_, callback_.callback())); | 472 net_log_, callback_.callback())); |
| 458 | 473 |
| 459 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, | 474 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, |
| 460 callback_.callback())); | 475 callback_.callback())); |
| 461 | 476 |
| 462 session_->connection()->CloseConnection(QUIC_NO_ERROR, true); | 477 session_->connection()->CloseConnection(QUIC_NO_ERROR, true); |
| 463 | 478 |
| 464 EXPECT_NE(OK, stream_->ReadResponseHeaders(callback_.callback())); | 479 EXPECT_NE(OK, stream_->ReadResponseHeaders(callback_.callback())); |
| 480 |
| 481 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 482 // payload. |
| 483 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
| 484 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
| 465 } | 485 } |
| 466 | 486 |
| 467 TEST_P(QuicHttpStreamTest, SendPostRequest) { | 487 TEST_P(QuicHttpStreamTest, SendPostRequest) { |
| 468 SetRequest("POST", "/", DEFAULT_PRIORITY); | 488 SetRequest("POST", "/", DEFAULT_PRIORITY); |
| 469 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); | 489 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); |
| 470 AddWrite(ConstructDataPacket(2, kIncludeVersion, kFin, 0, kUploadData)); | 490 AddWrite(ConstructDataPacket(2, kIncludeVersion, kFin, 0, kUploadData)); |
| 471 AddWrite(ConstructAckPacket(3, 3, 1)); | 491 AddWrite(ConstructAckPacket(3, 3, 1)); |
| 472 | 492 |
| 473 Initialize(); | 493 Initialize(); |
| 474 | 494 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 503 // Send the response body. | 523 // Send the response body. |
| 504 const char kResponseBody[] = "Hello world!"; | 524 const char kResponseBody[] = "Hello world!"; |
| 505 ProcessPacket(ConstructDataPacket(3, false, kFin, 0, kResponseBody)); | 525 ProcessPacket(ConstructDataPacket(3, false, kFin, 0, kResponseBody)); |
| 506 // Since the body has already arrived, this should return immediately. | 526 // Since the body has already arrived, this should return immediately. |
| 507 EXPECT_EQ(static_cast<int>(strlen(kResponseBody)), | 527 EXPECT_EQ(static_cast<int>(strlen(kResponseBody)), |
| 508 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 528 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
| 509 callback_.callback())); | 529 callback_.callback())); |
| 510 | 530 |
| 511 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 531 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 512 EXPECT_TRUE(AtEof()); | 532 EXPECT_TRUE(AtEof()); |
| 533 |
| 534 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 535 // payload. |
| 536 EXPECT_EQ(static_cast<int64_t>(strlen(kUploadData)), |
| 537 stream_->GetTotalSentBytes()); |
| 538 EXPECT_EQ(static_cast<int64_t>(strlen(kResponseBody)), |
| 539 stream_->GetTotalReceivedBytes()); |
| 513 } | 540 } |
| 514 | 541 |
| 515 TEST_P(QuicHttpStreamTest, SendChunkedPostRequest) { | 542 TEST_P(QuicHttpStreamTest, SendChunkedPostRequest) { |
| 516 SetRequest("POST", "/", DEFAULT_PRIORITY); | 543 SetRequest("POST", "/", DEFAULT_PRIORITY); |
| 517 size_t chunk_size = strlen(kUploadData); | 544 size_t chunk_size = strlen(kUploadData); |
| 518 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); | 545 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); |
| 519 AddWrite(ConstructDataPacket(2, kIncludeVersion, !kFin, 0, kUploadData)); | 546 AddWrite(ConstructDataPacket(2, kIncludeVersion, !kFin, 0, kUploadData)); |
| 520 AddWrite(ConstructDataPacket(3, kIncludeVersion, kFin, chunk_size, | 547 AddWrite(ConstructDataPacket(3, kIncludeVersion, kFin, chunk_size, |
| 521 kUploadData)); | 548 kUploadData)); |
| 522 AddWrite(ConstructAckPacket(4, 3, 1)); | 549 AddWrite(ConstructAckPacket(4, 3, 1)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), | 585 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), |
| 559 kResponseBody)); | 586 kResponseBody)); |
| 560 | 587 |
| 561 // Since the body has already arrived, this should return immediately. | 588 // Since the body has already arrived, this should return immediately. |
| 562 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), | 589 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), |
| 563 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 590 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
| 564 callback_.callback())); | 591 callback_.callback())); |
| 565 | 592 |
| 566 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 593 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 567 EXPECT_TRUE(AtEof()); | 594 EXPECT_TRUE(AtEof()); |
| 595 |
| 596 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 597 // payload. |
| 598 EXPECT_EQ(static_cast<int64_t>(strlen(kUploadData) * 2), |
| 599 stream_->GetTotalSentBytes()); |
| 600 EXPECT_EQ(static_cast<int64_t>(strlen(kResponseBody)), |
| 601 stream_->GetTotalReceivedBytes()); |
| 568 } | 602 } |
| 569 | 603 |
| 570 TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithFinalEmptyDataPacket) { | 604 TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithFinalEmptyDataPacket) { |
| 571 SetRequest("POST", "/", DEFAULT_PRIORITY); | 605 SetRequest("POST", "/", DEFAULT_PRIORITY); |
| 572 size_t chunk_size = strlen(kUploadData); | 606 size_t chunk_size = strlen(kUploadData); |
| 573 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); | 607 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); |
| 574 AddWrite(ConstructDataPacket(2, kIncludeVersion, !kFin, 0, kUploadData)); | 608 AddWrite(ConstructDataPacket(2, kIncludeVersion, !kFin, 0, kUploadData)); |
| 575 AddWrite(ConstructDataPacket(3, kIncludeVersion, kFin, chunk_size, "")); | 609 AddWrite(ConstructDataPacket(3, kIncludeVersion, kFin, chunk_size, "")); |
| 576 AddWrite(ConstructAckPacket(4, 3, 1)); | 610 AddWrite(ConstructAckPacket(4, 3, 1)); |
| 577 Initialize(); | 611 Initialize(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 const char kResponseBody[] = "Hello world!"; | 644 const char kResponseBody[] = "Hello world!"; |
| 611 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), | 645 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), |
| 612 kResponseBody)); | 646 kResponseBody)); |
| 613 | 647 |
| 614 // The body has arrived, but it is delivered asynchronously | 648 // The body has arrived, but it is delivered asynchronously |
| 615 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), | 649 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), |
| 616 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 650 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
| 617 callback_.callback())); | 651 callback_.callback())); |
| 618 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 652 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 619 EXPECT_TRUE(AtEof()); | 653 EXPECT_TRUE(AtEof()); |
| 654 |
| 655 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 656 // payload. |
| 657 EXPECT_EQ(static_cast<int64_t>(strlen(kUploadData)), |
| 658 stream_->GetTotalSentBytes()); |
| 659 EXPECT_EQ(static_cast<int64_t>(strlen(kResponseBody)), |
| 660 stream_->GetTotalReceivedBytes()); |
| 620 } | 661 } |
| 621 | 662 |
| 622 TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithOneEmptyDataPacket) { | 663 TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithOneEmptyDataPacket) { |
| 623 SetRequest("POST", "/", DEFAULT_PRIORITY); | 664 SetRequest("POST", "/", DEFAULT_PRIORITY); |
| 624 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); | 665 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); |
| 625 AddWrite(ConstructDataPacket(2, kIncludeVersion, kFin, 0, "")); | 666 AddWrite(ConstructDataPacket(2, kIncludeVersion, kFin, 0, "")); |
| 626 AddWrite(ConstructAckPacket(3, 3, 1)); | 667 AddWrite(ConstructAckPacket(3, 3, 1)); |
| 627 Initialize(); | 668 Initialize(); |
| 628 | 669 |
| 629 ChunkedUploadDataStream upload_data_stream(0); | 670 ChunkedUploadDataStream upload_data_stream(0); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 660 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), | 701 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), |
| 661 kResponseBody)); | 702 kResponseBody)); |
| 662 | 703 |
| 663 // The body has arrived, but it is delivered asynchronously | 704 // The body has arrived, but it is delivered asynchronously |
| 664 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), | 705 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), |
| 665 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 706 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
| 666 callback_.callback())); | 707 callback_.callback())); |
| 667 | 708 |
| 668 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 709 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 669 EXPECT_TRUE(AtEof()); | 710 EXPECT_TRUE(AtEof()); |
| 711 |
| 712 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 713 // payload. |
| 714 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
| 715 EXPECT_EQ(static_cast<int64_t>(strlen(kResponseBody)), |
| 716 stream_->GetTotalReceivedBytes()); |
| 670 } | 717 } |
| 671 | 718 |
| 672 TEST_P(QuicHttpStreamTest, DestroyedEarly) { | 719 TEST_P(QuicHttpStreamTest, DestroyedEarly) { |
| 673 SetRequest("GET", "/", DEFAULT_PRIORITY); | 720 SetRequest("GET", "/", DEFAULT_PRIORITY); |
| 674 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); | 721 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); |
| 675 if (!FLAGS_quic_process_frames_inline) { | 722 if (!FLAGS_quic_process_frames_inline) { |
| 676 AddWrite(ConstructRstStreamCancelledPacket(2)); | 723 AddWrite(ConstructRstStreamCancelledPacket(2)); |
| 677 } else { | 724 } else { |
| 678 AddWrite(ConstructAckAndRstStreamPacket(2)); | 725 AddWrite(ConstructAckAndRstStreamPacket(2)); |
| 679 } | 726 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 694 stream_->ReadResponseHeaders(callback_.callback())); | 741 stream_->ReadResponseHeaders(callback_.callback())); |
| 695 | 742 |
| 696 // Send the response with a body. | 743 // Send the response with a body. |
| 697 SetResponse("404 OK", "hello world!"); | 744 SetResponse("404 OK", "hello world!"); |
| 698 // In the course of processing this packet, the QuicHttpStream close itself. | 745 // In the course of processing this packet, the QuicHttpStream close itself. |
| 699 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); | 746 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); |
| 700 | 747 |
| 701 base::MessageLoop::current()->RunUntilIdle(); | 748 base::MessageLoop::current()->RunUntilIdle(); |
| 702 | 749 |
| 703 EXPECT_TRUE(AtEof()); | 750 EXPECT_TRUE(AtEof()); |
| 751 |
| 752 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 753 // payload. |
| 754 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
| 755 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
| 704 } | 756 } |
| 705 | 757 |
| 706 TEST_P(QuicHttpStreamTest, Priority) { | 758 TEST_P(QuicHttpStreamTest, Priority) { |
| 707 SetRequest("GET", "/", MEDIUM); | 759 SetRequest("GET", "/", MEDIUM); |
| 708 AddWrite(ConstructRequestHeadersPacket(1, kFin, MEDIUM)); | 760 AddWrite(ConstructRequestHeadersPacket(1, kFin, MEDIUM)); |
| 709 if (!FLAGS_quic_process_frames_inline) { | 761 if (!FLAGS_quic_process_frames_inline) { |
| 710 AddWrite(ConstructRstStreamCancelledPacket(2)); | 762 AddWrite(ConstructRstStreamCancelledPacket(2)); |
| 711 } else { | 763 } else { |
| 712 AddWrite(ConstructAckAndRstStreamPacket(2)); | 764 AddWrite(ConstructAckAndRstStreamPacket(2)); |
| 713 } | 765 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 740 stream_->ReadResponseHeaders(callback_.callback())); | 792 stream_->ReadResponseHeaders(callback_.callback())); |
| 741 | 793 |
| 742 // Send the response with a body. | 794 // Send the response with a body. |
| 743 SetResponse("404 OK", "hello world!"); | 795 SetResponse("404 OK", "hello world!"); |
| 744 // In the course of processing this packet, the QuicHttpStream close itself. | 796 // In the course of processing this packet, the QuicHttpStream close itself. |
| 745 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); | 797 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); |
| 746 | 798 |
| 747 base::MessageLoop::current()->RunUntilIdle(); | 799 base::MessageLoop::current()->RunUntilIdle(); |
| 748 | 800 |
| 749 EXPECT_TRUE(AtEof()); | 801 EXPECT_TRUE(AtEof()); |
| 802 |
| 803 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 804 // payload. |
| 805 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
| 806 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
| 750 } | 807 } |
| 751 | 808 |
| 752 // Regression test for http://crbug.com/294870 | 809 // Regression test for http://crbug.com/294870 |
| 753 TEST_P(QuicHttpStreamTest, CheckPriorityWithNoDelegate) { | 810 TEST_P(QuicHttpStreamTest, CheckPriorityWithNoDelegate) { |
| 754 SetRequest("GET", "/", MEDIUM); | 811 SetRequest("GET", "/", MEDIUM); |
| 755 use_closing_stream_ = true; | 812 use_closing_stream_ = true; |
| 756 | 813 |
| 757 AddWrite(ConstructRstStreamPacket(1)); | 814 AddWrite(ConstructRstStreamPacket(1)); |
| 758 | 815 |
| 759 Initialize(); | 816 Initialize(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 772 DCHECK(delegate); | 829 DCHECK(delegate); |
| 773 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, | 830 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, |
| 774 reliable_stream->EffectivePriority()); | 831 reliable_stream->EffectivePriority()); |
| 775 | 832 |
| 776 // Set Delegate to nullptr and make sure EffectivePriority returns highest | 833 // Set Delegate to nullptr and make sure EffectivePriority returns highest |
| 777 // priority. | 834 // priority. |
| 778 reliable_stream->SetDelegate(nullptr); | 835 reliable_stream->SetDelegate(nullptr); |
| 779 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, | 836 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, |
| 780 reliable_stream->EffectivePriority()); | 837 reliable_stream->EffectivePriority()); |
| 781 reliable_stream->SetDelegate(delegate); | 838 reliable_stream->SetDelegate(delegate); |
| 839 |
| 840 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the |
| 841 // payload. |
| 842 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
| 843 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
| 782 } | 844 } |
| 783 | 845 |
| 784 } // namespace test | 846 } // namespace test |
| 785 } // namespace net | 847 } // namespace net |
| OLD | NEW |