Chromium Code Reviews| 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 381 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
| 380 EXPECT_FALSE(response_.response_time.is_null()); | 382 EXPECT_FALSE(response_.response_time.is_null()); |
| 381 EXPECT_FALSE(response_.request_time.is_null()); | 383 EXPECT_FALSE(response_.request_time.is_null()); |
| 382 | 384 |
| 383 // There is no body, so this should return immediately. | 385 // There is no body, so this should return immediately. |
| 384 EXPECT_EQ(0, stream_->ReadResponseBody(read_buffer_.get(), | 386 EXPECT_EQ(0, stream_->ReadResponseBody(read_buffer_.get(), |
| 385 read_buffer_->size(), | 387 read_buffer_->size(), |
| 386 callback_.callback())); | 388 callback_.callback())); |
| 387 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 389 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 388 EXPECT_TRUE(AtEof()); | 390 EXPECT_TRUE(AtEof()); |
| 391 | |
| 392 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | |
|
bengr
2015/09/01 17:16:06
Does "currently" suggest a TODO?
sclittle
2015/09/02 00:06:23
Sure, added a TODO in quic_http_stream.cc.
| |
| 393 // payload. | |
| 394 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | |
| 395 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | |
| 389 } | 396 } |
| 390 | 397 |
| 391 // Regression test for http://crbug.com/288128 | 398 // Regression test for http://crbug.com/288128 |
| 392 TEST_P(QuicHttpStreamTest, GetRequestLargeResponse) { | 399 TEST_P(QuicHttpStreamTest, GetRequestLargeResponse) { |
| 393 SetRequest("GET", "/", DEFAULT_PRIORITY); | 400 SetRequest("GET", "/", DEFAULT_PRIORITY); |
| 394 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); | 401 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); |
| 395 Initialize(); | 402 Initialize(); |
| 396 | 403 |
| 397 request_.method = "GET"; | 404 request_.method = "GET"; |
| 398 request_.url = GURL("http://www.google.com/"); | 405 request_.url = GURL("http://www.google.com/"); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 422 ASSERT_TRUE(response_.headers.get()); | 429 ASSERT_TRUE(response_.headers.get()); |
| 423 EXPECT_EQ(200, response_.headers->response_code()); | 430 EXPECT_EQ(200, response_.headers->response_code()); |
| 424 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 431 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
| 425 | 432 |
| 426 // There is no body, so this should return immediately. | 433 // There is no body, so this should return immediately. |
| 427 EXPECT_EQ(0, stream_->ReadResponseBody(read_buffer_.get(), | 434 EXPECT_EQ(0, stream_->ReadResponseBody(read_buffer_.get(), |
| 428 read_buffer_->size(), | 435 read_buffer_->size(), |
| 429 callback_.callback())); | 436 callback_.callback())); |
| 430 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 437 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 431 EXPECT_TRUE(AtEof()); | 438 EXPECT_TRUE(AtEof()); |
| 439 | |
| 440 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | |
| 441 // payload. | |
| 442 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | |
| 443 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | |
| 432 } | 444 } |
| 433 | 445 |
| 434 // Regression test for http://crbug.com/409101 | 446 // Regression test for http://crbug.com/409101 |
| 435 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendRequest) { | 447 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendRequest) { |
| 436 SetRequest("GET", "/", DEFAULT_PRIORITY); | 448 SetRequest("GET", "/", DEFAULT_PRIORITY); |
| 437 Initialize(); | 449 Initialize(); |
| 438 | 450 |
| 439 request_.method = "GET"; | 451 request_.method = "GET"; |
| 440 request_.url = GURL("http://www.google.com/"); | 452 request_.url = GURL("http://www.google.com/"); |
| 441 | 453 |
| 442 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 454 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 443 net_log_, callback_.callback())); | 455 net_log_, callback_.callback())); |
| 444 | 456 |
| 445 session_->connection()->CloseConnection(QUIC_NO_ERROR, true); | 457 session_->connection()->CloseConnection(QUIC_NO_ERROR, true); |
| 446 | 458 |
| 447 EXPECT_EQ(ERR_CONNECTION_CLOSED, | 459 EXPECT_EQ(ERR_CONNECTION_CLOSED, |
| 448 stream_->SendRequest(headers_, &response_, | 460 stream_->SendRequest(headers_, &response_, |
| 449 callback_.callback())); | 461 callback_.callback())); |
| 462 | |
| 463 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | |
| 464 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | |
| 450 } | 465 } |
| 451 | 466 |
| 452 // Regression test for http://crbug.com/409871 | 467 // Regression test for http://crbug.com/409871 |
| 453 TEST_P(QuicHttpStreamTest, SessionClosedBeforeReadResponseHeaders) { | 468 TEST_P(QuicHttpStreamTest, SessionClosedBeforeReadResponseHeaders) { |
| 454 SetRequest("GET", "/", DEFAULT_PRIORITY); | 469 SetRequest("GET", "/", DEFAULT_PRIORITY); |
| 455 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); | 470 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); |
| 456 Initialize(); | 471 Initialize(); |
| 457 | 472 |
| 458 request_.method = "GET"; | 473 request_.method = "GET"; |
| 459 request_.url = GURL("http://www.google.com/"); | 474 request_.url = GURL("http://www.google.com/"); |
| 460 | 475 |
| 461 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 476 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 462 net_log_, callback_.callback())); | 477 net_log_, callback_.callback())); |
| 463 | 478 |
| 464 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, | 479 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, |
| 465 callback_.callback())); | 480 callback_.callback())); |
| 466 | 481 |
| 467 session_->connection()->CloseConnection(QUIC_NO_ERROR, true); | 482 session_->connection()->CloseConnection(QUIC_NO_ERROR, true); |
| 468 | 483 |
| 469 EXPECT_NE(OK, stream_->ReadResponseHeaders(callback_.callback())); | 484 EXPECT_NE(OK, stream_->ReadResponseHeaders(callback_.callback())); |
| 485 | |
| 486 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | |
| 487 // payload. | |
| 488 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | |
| 489 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | |
| 470 } | 490 } |
| 471 | 491 |
| 472 TEST_P(QuicHttpStreamTest, SendPostRequest) { | 492 TEST_P(QuicHttpStreamTest, SendPostRequest) { |
| 473 SetRequest("POST", "/", DEFAULT_PRIORITY); | 493 SetRequest("POST", "/", DEFAULT_PRIORITY); |
| 474 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); | 494 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); |
| 475 AddWrite(ConstructDataPacket(2, kIncludeVersion, kFin, 0, kUploadData)); | 495 AddWrite(ConstructDataPacket(2, kIncludeVersion, kFin, 0, kUploadData)); |
| 476 AddWrite(ConstructAckPacket(3, 3, 1)); | 496 AddWrite(ConstructAckPacket(3, 3, 1)); |
| 477 | 497 |
| 478 Initialize(); | 498 Initialize(); |
| 479 | 499 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 508 // Send the response body. | 528 // Send the response body. |
| 509 const char kResponseBody[] = "Hello world!"; | 529 const char kResponseBody[] = "Hello world!"; |
| 510 ProcessPacket(ConstructDataPacket(3, false, kFin, 0, kResponseBody)); | 530 ProcessPacket(ConstructDataPacket(3, false, kFin, 0, kResponseBody)); |
| 511 // Since the body has already arrived, this should return immediately. | 531 // Since the body has already arrived, this should return immediately. |
| 512 EXPECT_EQ(static_cast<int>(strlen(kResponseBody)), | 532 EXPECT_EQ(static_cast<int>(strlen(kResponseBody)), |
| 513 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 533 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
| 514 callback_.callback())); | 534 callback_.callback())); |
| 515 | 535 |
| 516 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 536 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 517 EXPECT_TRUE(AtEof()); | 537 EXPECT_TRUE(AtEof()); |
| 538 | |
| 539 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | |
| 540 // payload. | |
| 541 EXPECT_EQ(static_cast<int64_t>(strlen(kUploadData)), | |
| 542 stream_->GetTotalSentBytes()); | |
| 543 EXPECT_EQ(static_cast<int64_t>(strlen(kResponseBody)), | |
| 544 stream_->GetTotalReceivedBytes()); | |
| 518 } | 545 } |
| 519 | 546 |
| 520 TEST_P(QuicHttpStreamTest, SendChunkedPostRequest) { | 547 TEST_P(QuicHttpStreamTest, SendChunkedPostRequest) { |
| 521 SetRequest("POST", "/", DEFAULT_PRIORITY); | 548 SetRequest("POST", "/", DEFAULT_PRIORITY); |
| 522 size_t chunk_size = strlen(kUploadData); | 549 size_t chunk_size = strlen(kUploadData); |
| 523 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); | 550 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); |
| 524 AddWrite(ConstructDataPacket(2, kIncludeVersion, !kFin, 0, kUploadData)); | 551 AddWrite(ConstructDataPacket(2, kIncludeVersion, !kFin, 0, kUploadData)); |
| 525 AddWrite(ConstructDataPacket(3, kIncludeVersion, kFin, chunk_size, | 552 AddWrite(ConstructDataPacket(3, kIncludeVersion, kFin, chunk_size, |
| 526 kUploadData)); | 553 kUploadData)); |
| 527 AddWrite(ConstructAckPacket(4, 3, 1)); | 554 AddWrite(ConstructAckPacket(4, 3, 1)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), | 590 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), |
| 564 kResponseBody)); | 591 kResponseBody)); |
| 565 | 592 |
| 566 // Since the body has already arrived, this should return immediately. | 593 // Since the body has already arrived, this should return immediately. |
| 567 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), | 594 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), |
| 568 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 595 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
| 569 callback_.callback())); | 596 callback_.callback())); |
| 570 | 597 |
| 571 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 598 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 572 EXPECT_TRUE(AtEof()); | 599 EXPECT_TRUE(AtEof()); |
| 600 | |
| 601 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | |
| 602 // payload. | |
| 603 EXPECT_EQ(static_cast<int64_t>(strlen(kUploadData) * 2), | |
|
bengr
2015/09/01 17:16:06
Why *2?
sclittle
2015/09/02 00:06:23
Because 2 chunks of kUploadData were sent with the
| |
| 604 stream_->GetTotalSentBytes()); | |
| 605 EXPECT_EQ(static_cast<int64_t>(strlen(kResponseBody)), | |
| 606 stream_->GetTotalReceivedBytes()); | |
| 573 } | 607 } |
| 574 | 608 |
| 575 TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithFinalEmptyDataPacket) { | 609 TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithFinalEmptyDataPacket) { |
| 576 SetRequest("POST", "/", DEFAULT_PRIORITY); | 610 SetRequest("POST", "/", DEFAULT_PRIORITY); |
| 577 size_t chunk_size = strlen(kUploadData); | 611 size_t chunk_size = strlen(kUploadData); |
| 578 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); | 612 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); |
| 579 AddWrite(ConstructDataPacket(2, kIncludeVersion, !kFin, 0, kUploadData)); | 613 AddWrite(ConstructDataPacket(2, kIncludeVersion, !kFin, 0, kUploadData)); |
| 580 AddWrite(ConstructDataPacket(3, kIncludeVersion, kFin, chunk_size, "")); | 614 AddWrite(ConstructDataPacket(3, kIncludeVersion, kFin, chunk_size, "")); |
| 581 AddWrite(ConstructAckPacket(4, 3, 1)); | 615 AddWrite(ConstructAckPacket(4, 3, 1)); |
| 582 Initialize(); | 616 Initialize(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 const char kResponseBody[] = "Hello world!"; | 649 const char kResponseBody[] = "Hello world!"; |
| 616 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), | 650 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), |
| 617 kResponseBody)); | 651 kResponseBody)); |
| 618 | 652 |
| 619 // The body has arrived, but it is delivered asynchronously | 653 // The body has arrived, but it is delivered asynchronously |
| 620 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), | 654 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), |
| 621 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 655 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
| 622 callback_.callback())); | 656 callback_.callback())); |
| 623 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 657 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 624 EXPECT_TRUE(AtEof()); | 658 EXPECT_TRUE(AtEof()); |
| 659 | |
| 660 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | |
| 661 // payload. | |
| 662 EXPECT_EQ(static_cast<int64_t>(strlen(kUploadData)), | |
| 663 stream_->GetTotalSentBytes()); | |
| 664 EXPECT_EQ(static_cast<int64_t>(strlen(kResponseBody)), | |
| 665 stream_->GetTotalReceivedBytes()); | |
| 625 } | 666 } |
| 626 | 667 |
| 627 TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithOneEmptyDataPacket) { | 668 TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithOneEmptyDataPacket) { |
| 628 SetRequest("POST", "/", DEFAULT_PRIORITY); | 669 SetRequest("POST", "/", DEFAULT_PRIORITY); |
| 629 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); | 670 AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY)); |
| 630 AddWrite(ConstructDataPacket(2, kIncludeVersion, kFin, 0, "")); | 671 AddWrite(ConstructDataPacket(2, kIncludeVersion, kFin, 0, "")); |
| 631 AddWrite(ConstructAckPacket(3, 3, 1)); | 672 AddWrite(ConstructAckPacket(3, 3, 1)); |
| 632 Initialize(); | 673 Initialize(); |
| 633 | 674 |
| 634 ChunkedUploadDataStream upload_data_stream(0); | 675 ChunkedUploadDataStream upload_data_stream(0); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 665 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), | 706 ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(), |
| 666 kResponseBody)); | 707 kResponseBody)); |
| 667 | 708 |
| 668 // The body has arrived, but it is delivered asynchronously | 709 // The body has arrived, but it is delivered asynchronously |
| 669 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), | 710 ASSERT_EQ(static_cast<int>(strlen(kResponseBody)), |
| 670 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 711 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
| 671 callback_.callback())); | 712 callback_.callback())); |
| 672 | 713 |
| 673 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 714 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
| 674 EXPECT_TRUE(AtEof()); | 715 EXPECT_TRUE(AtEof()); |
| 716 | |
| 717 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | |
| 718 // payload. | |
| 719 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | |
| 720 EXPECT_EQ(static_cast<int64_t>(strlen(kResponseBody)), | |
| 721 stream_->GetTotalReceivedBytes()); | |
| 675 } | 722 } |
| 676 | 723 |
| 677 TEST_P(QuicHttpStreamTest, DestroyedEarly) { | 724 TEST_P(QuicHttpStreamTest, DestroyedEarly) { |
| 678 SetRequest("GET", "/", DEFAULT_PRIORITY); | 725 SetRequest("GET", "/", DEFAULT_PRIORITY); |
| 679 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); | 726 AddWrite(ConstructRequestHeadersPacket(1, kFin, DEFAULT_PRIORITY)); |
| 680 if (!FLAGS_quic_process_frames_inline) { | 727 if (!FLAGS_quic_process_frames_inline) { |
| 681 AddWrite(ConstructRstStreamCancelledPacket(2)); | 728 AddWrite(ConstructRstStreamCancelledPacket(2)); |
| 682 } else { | 729 } else { |
| 683 AddWrite(ConstructAckAndRstStreamPacket(2)); | 730 AddWrite(ConstructAckAndRstStreamPacket(2)); |
| 684 } | 731 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 699 stream_->ReadResponseHeaders(callback_.callback())); | 746 stream_->ReadResponseHeaders(callback_.callback())); |
| 700 | 747 |
| 701 // Send the response with a body. | 748 // Send the response with a body. |
| 702 SetResponse("404 OK", "hello world!"); | 749 SetResponse("404 OK", "hello world!"); |
| 703 // In the course of processing this packet, the QuicHttpStream close itself. | 750 // In the course of processing this packet, the QuicHttpStream close itself. |
| 704 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); | 751 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); |
| 705 | 752 |
| 706 base::MessageLoop::current()->RunUntilIdle(); | 753 base::MessageLoop::current()->RunUntilIdle(); |
| 707 | 754 |
| 708 EXPECT_TRUE(AtEof()); | 755 EXPECT_TRUE(AtEof()); |
| 756 | |
| 757 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | |
| 758 // payload. | |
| 759 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | |
| 760 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | |
| 709 } | 761 } |
| 710 | 762 |
| 711 TEST_P(QuicHttpStreamTest, Priority) { | 763 TEST_P(QuicHttpStreamTest, Priority) { |
| 712 SetRequest("GET", "/", MEDIUM); | 764 SetRequest("GET", "/", MEDIUM); |
| 713 AddWrite(ConstructRequestHeadersPacket(1, kFin, MEDIUM)); | 765 AddWrite(ConstructRequestHeadersPacket(1, kFin, MEDIUM)); |
| 714 if (!FLAGS_quic_process_frames_inline) { | 766 if (!FLAGS_quic_process_frames_inline) { |
| 715 AddWrite(ConstructRstStreamCancelledPacket(2)); | 767 AddWrite(ConstructRstStreamCancelledPacket(2)); |
| 716 } else { | 768 } else { |
| 717 AddWrite(ConstructAckAndRstStreamPacket(2)); | 769 AddWrite(ConstructAckAndRstStreamPacket(2)); |
| 718 } | 770 } |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 745 stream_->ReadResponseHeaders(callback_.callback())); | 797 stream_->ReadResponseHeaders(callback_.callback())); |
| 746 | 798 |
| 747 // Send the response with a body. | 799 // Send the response with a body. |
| 748 SetResponse("404 OK", "hello world!"); | 800 SetResponse("404 OK", "hello world!"); |
| 749 // In the course of processing this packet, the QuicHttpStream close itself. | 801 // In the course of processing this packet, the QuicHttpStream close itself. |
| 750 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); | 802 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); |
| 751 | 803 |
| 752 base::MessageLoop::current()->RunUntilIdle(); | 804 base::MessageLoop::current()->RunUntilIdle(); |
| 753 | 805 |
| 754 EXPECT_TRUE(AtEof()); | 806 EXPECT_TRUE(AtEof()); |
| 807 | |
| 808 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | |
| 809 // payload. | |
| 810 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | |
| 811 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | |
| 755 } | 812 } |
| 756 | 813 |
| 757 // Regression test for http://crbug.com/294870 | 814 // Regression test for http://crbug.com/294870 |
| 758 TEST_P(QuicHttpStreamTest, CheckPriorityWithNoDelegate) { | 815 TEST_P(QuicHttpStreamTest, CheckPriorityWithNoDelegate) { |
| 759 SetRequest("GET", "/", MEDIUM); | 816 SetRequest("GET", "/", MEDIUM); |
| 760 use_closing_stream_ = true; | 817 use_closing_stream_ = true; |
| 761 | 818 |
| 762 AddWrite(ConstructRstStreamPacket(1)); | 819 AddWrite(ConstructRstStreamPacket(1)); |
| 763 | 820 |
| 764 Initialize(); | 821 Initialize(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 777 DCHECK(delegate); | 834 DCHECK(delegate); |
| 778 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, | 835 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, |
| 779 reliable_stream->EffectivePriority()); | 836 reliable_stream->EffectivePriority()); |
| 780 | 837 |
| 781 // Set Delegate to nullptr and make sure EffectivePriority returns highest | 838 // Set Delegate to nullptr and make sure EffectivePriority returns highest |
| 782 // priority. | 839 // priority. |
| 783 reliable_stream->SetDelegate(nullptr); | 840 reliable_stream->SetDelegate(nullptr); |
| 784 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, | 841 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, |
| 785 reliable_stream->EffectivePriority()); | 842 reliable_stream->EffectivePriority()); |
| 786 reliable_stream->SetDelegate(delegate); | 843 reliable_stream->SetDelegate(delegate); |
| 844 | |
| 845 // QuicHttpStream::GetTotalSent/ReceivedBytes currently only includes the | |
| 846 // payload. | |
| 847 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | |
| 848 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | |
| 787 } | 849 } |
| 788 | 850 |
| 789 } // namespace test | 851 } // namespace test |
| 790 } // namespace net | 852 } // namespace net |
| OLD | NEW |