| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_headers_stream.h" | 5 #include "net/quic/quic_headers_stream.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" |
| 9 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
| 10 #include "net/quic/spdy_utils.h" | 11 #include "net/quic/spdy_utils.h" |
| 11 #include "net/quic/test_tools/quic_connection_peer.h" | 12 #include "net/quic/test_tools/quic_connection_peer.h" |
| 12 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 13 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
| 13 #include "net/quic/test_tools/quic_test_utils.h" | 14 #include "net/quic/test_tools/quic_test_utils.h" |
| 14 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 15 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
| 15 #include "net/spdy/spdy_alt_svc_wire_format.h" | 16 #include "net/spdy/spdy_alt_svc_wire_format.h" |
| 16 #include "net/spdy/spdy_flags.h" | 17 #include "net/spdy/spdy_flags.h" |
| 17 #include "net/spdy/spdy_protocol.h" | 18 #include "net/spdy/spdy_protocol.h" |
| 18 #include "net/spdy/spdy_test_utils.h" | 19 #include "net/spdy/spdy_test_utils.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 37 class MockHpackDebugVisitor : public QuicHeadersStream::HpackDebugVisitor { | 38 class MockHpackDebugVisitor : public QuicHeadersStream::HpackDebugVisitor { |
| 38 public: | 39 public: |
| 39 explicit MockHpackDebugVisitor() : HpackDebugVisitor() {} | 40 explicit MockHpackDebugVisitor() : HpackDebugVisitor() {} |
| 40 | 41 |
| 41 MOCK_METHOD1(OnUseEntry, void(QuicTime::Delta elapsed)); | 42 MOCK_METHOD1(OnUseEntry, void(QuicTime::Delta elapsed)); |
| 42 | 43 |
| 43 private: | 44 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(MockHpackDebugVisitor); | 45 DISALLOW_COPY_AND_ASSIGN(MockHpackDebugVisitor); |
| 45 }; | 46 }; |
| 46 | 47 |
| 48 class QuicHeadersStreamPeer { |
| 49 public: |
| 50 static const SpdyFramer& GetSpdyFramer(QuicHeadersStream* stream) { |
| 51 return stream->spdy_framer_; |
| 52 } |
| 53 }; |
| 54 |
| 47 namespace { | 55 namespace { |
| 48 | 56 |
| 49 // TODO(ckrasic): this workaround is due to absence of std::initializer_list | 57 // TODO(ckrasic): this workaround is due to absence of std::initializer_list |
| 50 const bool kFins[] = {false, true}; | 58 const bool kFins[] = {false, true}; |
| 51 | 59 |
| 52 class MockVisitor : public SpdyFramerVisitorInterface { | 60 class MockVisitor : public SpdyFramerVisitorInterface { |
| 53 public: | 61 public: |
| 54 MOCK_METHOD1(OnError, void(SpdyFramer* framer)); | 62 MOCK_METHOD1(OnError, void(SpdyFramer* framer)); |
| 55 MOCK_METHOD3(OnDataFrameHeader, | 63 MOCK_METHOD3(OnDataFrameHeader, |
| 56 void(SpdyStreamId stream_id, size_t length, bool fin)); | 64 void(SpdyStreamId stream_id, size_t length, bool fin)); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, | 571 CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 564 "SPDY RST_STREAM frame received.", _)) | 572 "SPDY RST_STREAM frame received.", _)) |
| 565 .WillOnce(InvokeWithoutArgs( | 573 .WillOnce(InvokeWithoutArgs( |
| 566 this, &QuicHeadersStreamTest::TearDownLocalConnectionState)); | 574 this, &QuicHeadersStreamTest::TearDownLocalConnectionState)); |
| 567 stream_frame_.data_buffer = frame.data(); | 575 stream_frame_.data_buffer = frame.data(); |
| 568 stream_frame_.data_length = frame.size(); | 576 stream_frame_.data_length = frame.size(); |
| 569 headers_stream_->OnStreamFrame(stream_frame_); | 577 headers_stream_->OnStreamFrame(stream_frame_); |
| 570 } | 578 } |
| 571 | 579 |
| 572 TEST_P(QuicHeadersStreamTest, ProcessSpdySettingsFrame) { | 580 TEST_P(QuicHeadersStreamTest, ProcessSpdySettingsFrame) { |
| 581 FLAGS_quic_respect_http2_settings_frame = false; |
| 573 SpdySettingsIR data; | 582 SpdySettingsIR data; |
| 574 data.AddSetting(SETTINGS_HEADER_TABLE_SIZE, true, true, 0); | 583 data.AddSetting(SETTINGS_HEADER_TABLE_SIZE, true, true, 0); |
| 575 SpdySerializedFrame frame(framer_->SerializeFrame(data)); | 584 SpdySerializedFrame frame(framer_->SerializeFrame(data)); |
| 576 EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, | 585 EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 577 "SPDY SETTINGS frame received.", _)) | 586 "SPDY SETTINGS frame received.", _)) |
| 578 .WillOnce(InvokeWithoutArgs( | 587 .WillOnce(InvokeWithoutArgs( |
| 579 this, &QuicHeadersStreamTest::TearDownLocalConnectionState)); | 588 this, &QuicHeadersStreamTest::TearDownLocalConnectionState)); |
| 580 stream_frame_.data_buffer = frame.data(); | 589 stream_frame_.data_buffer = frame.data(); |
| 581 stream_frame_.data_length = frame.size(); | 590 stream_frame_.data_length = frame.size(); |
| 582 headers_stream_->OnStreamFrame(stream_frame_); | 591 headers_stream_->OnStreamFrame(stream_frame_); |
| 583 } | 592 } |
| 584 | 593 |
| 594 TEST_P(QuicHeadersStreamTest, RespectHttp2SettingsFrameSupportedFields) { |
| 595 FLAGS_quic_respect_http2_settings_frame = true; |
| 596 const uint32_t kTestHeaderTableSize = 1000; |
| 597 SpdySettingsIR data; |
| 598 // Respect supported settings frames SETTINGS_HEADER_TABLE_SIZE. |
| 599 data.AddSetting(SETTINGS_HEADER_TABLE_SIZE, true, true, kTestHeaderTableSize); |
| 600 SpdySerializedFrame frame(framer_->SerializeFrame(data)); |
| 601 stream_frame_.data_buffer = frame.data(); |
| 602 stream_frame_.data_length = frame.size(); |
| 603 headers_stream_->OnStreamFrame(stream_frame_); |
| 604 EXPECT_EQ(kTestHeaderTableSize, |
| 605 QuicHeadersStreamPeer::GetSpdyFramer(headers_stream_) |
| 606 .header_encoder_table_size()); |
| 607 } |
| 608 |
| 609 TEST_P(QuicHeadersStreamTest, RespectHttp2SettingsFrameUnsupportedFields) { |
| 610 FLAGS_quic_respect_http2_settings_frame = true; |
| 611 SpdySettingsIR data; |
| 612 // Does not support SETTINGS_MAX_HEADER_LIST_SIZE, |
| 613 // SETTINGS_MAX_CONCURRENT_STREAMS, SETTINGS_INITIAL_WINDOW_SIZE, |
| 614 // SETTINGS_ENABLE_PUSH and SETTINGS_MAX_FRAME_SIZE. |
| 615 data.AddSetting(SETTINGS_MAX_HEADER_LIST_SIZE, true, true, 2000); |
| 616 data.AddSetting(SETTINGS_MAX_CONCURRENT_STREAMS, true, true, 100); |
| 617 data.AddSetting(SETTINGS_INITIAL_WINDOW_SIZE, true, true, 100); |
| 618 data.AddSetting(SETTINGS_ENABLE_PUSH, true, true, 1); |
| 619 data.AddSetting(SETTINGS_MAX_FRAME_SIZE, true, true, 1250); |
| 620 SpdySerializedFrame frame(framer_->SerializeFrame(data)); |
| 621 EXPECT_CALL( |
| 622 *connection_, |
| 623 CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 624 "Unsupported field of HTTP/2 SETTINGS frame: " + |
| 625 base::IntToString(SETTINGS_MAX_HEADER_LIST_SIZE), |
| 626 _)); |
| 627 EXPECT_CALL( |
| 628 *connection_, |
| 629 CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 630 "Unsupported field of HTTP/2 SETTINGS frame: " + |
| 631 base::IntToString(SETTINGS_MAX_CONCURRENT_STREAMS), |
| 632 _)); |
| 633 EXPECT_CALL( |
| 634 *connection_, |
| 635 CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 636 "Unsupported field of HTTP/2 SETTINGS frame: " + |
| 637 base::IntToString(SETTINGS_INITIAL_WINDOW_SIZE), |
| 638 _)); |
| 639 EXPECT_CALL(*connection_, |
| 640 CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 641 "Unsupported field of HTTP/2 SETTINGS frame: " + |
| 642 base::IntToString(SETTINGS_ENABLE_PUSH), |
| 643 _)); |
| 644 EXPECT_CALL(*connection_, |
| 645 CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 646 "Unsupported field of HTTP/2 SETTINGS frame: " + |
| 647 base::IntToString(SETTINGS_MAX_FRAME_SIZE), |
| 648 _)); |
| 649 stream_frame_.data_buffer = frame.data(); |
| 650 stream_frame_.data_length = frame.size(); |
| 651 headers_stream_->OnStreamFrame(stream_frame_); |
| 652 } |
| 653 |
| 585 TEST_P(QuicHeadersStreamTest, ProcessSpdyPingFrame) { | 654 TEST_P(QuicHeadersStreamTest, ProcessSpdyPingFrame) { |
| 586 SpdyPingIR data(1); | 655 SpdyPingIR data(1); |
| 587 SpdySerializedFrame frame(framer_->SerializeFrame(data)); | 656 SpdySerializedFrame frame(framer_->SerializeFrame(data)); |
| 588 EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, | 657 EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 589 "SPDY PING frame received.", _)) | 658 "SPDY PING frame received.", _)) |
| 590 .WillOnce(InvokeWithoutArgs( | 659 .WillOnce(InvokeWithoutArgs( |
| 591 this, &QuicHeadersStreamTest::TearDownLocalConnectionState)); | 660 this, &QuicHeadersStreamTest::TearDownLocalConnectionState)); |
| 592 stream_frame_.data_buffer = frame.data(); | 661 stream_frame_.data_buffer = frame.data(); |
| 593 stream_frame_.data_length = frame.size(); | 662 stream_frame_.data_length = frame.size(); |
| 594 headers_stream_->OnStreamFrame(stream_frame_); | 663 headers_stream_->OnStreamFrame(stream_frame_); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 connection_->AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); | 780 connection_->AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); |
| 712 } | 781 } |
| 713 } | 782 } |
| 714 } | 783 } |
| 715 } | 784 } |
| 716 } | 785 } |
| 717 | 786 |
| 718 } // namespace | 787 } // namespace |
| 719 } // namespace test | 788 } // namespace test |
| 720 } // namespace net | 789 } // namespace net |
| OLD | NEW |