OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/tools/quic/quic_spdy_server_stream.h" | 5 #include "net/tools/quic/quic_spdy_server_stream.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
10 #include "net/quic/quic_protocol.h" | 10 #include "net/quic/quic_protocol.h" |
11 #include "net/quic/quic_utils.h" | 11 #include "net/quic/quic_utils.h" |
12 #include "net/quic/spdy_utils.h" | 12 #include "net/quic/spdy_utils.h" |
13 #include "net/quic/test_tools/quic_test_utils.h" | 13 #include "net/quic/test_tools/quic_test_utils.h" |
14 #include "net/tools/epoll_server/epoll_server.h" | 14 #include "net/tools/epoll_server/epoll_server.h" |
15 #include "net/tools/quic/quic_in_memory_cache.h" | 15 #include "net/tools/quic/quic_in_memory_cache.h" |
16 #include "net/tools/quic/spdy_balsa_utils.h" | 16 #include "net/tools/quic/spdy_balsa_utils.h" |
17 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" | 17 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 using base::StringPiece; | 21 using base::StringPiece; |
22 using net::test::MockConnection; | 22 using net::test::MockConnection; |
23 using net::test::MockSession; | 23 using net::test::MockQuicSpdySession; |
24 using net::test::SupportedVersions; | 24 using net::test::SupportedVersions; |
25 using net::test::kInitialSessionFlowControlWindowForTest; | 25 using net::test::kInitialSessionFlowControlWindowForTest; |
26 using net::test::kInitialStreamFlowControlWindowForTest; | 26 using net::test::kInitialStreamFlowControlWindowForTest; |
27 using std::string; | 27 using std::string; |
28 using testing::_; | 28 using testing::_; |
29 using testing::AnyNumber; | 29 using testing::AnyNumber; |
30 using testing::Invoke; | 30 using testing::Invoke; |
31 using testing::InvokeArgument; | 31 using testing::InvokeArgument; |
32 using testing::InSequence; | 32 using testing::InSequence; |
33 using testing::Return; | 33 using testing::Return; |
34 using testing::StrictMock; | 34 using testing::StrictMock; |
35 using testing::WithArgs; | 35 using testing::WithArgs; |
36 | 36 |
37 namespace net { | 37 namespace net { |
38 namespace tools { | 38 namespace tools { |
39 namespace test { | 39 namespace test { |
40 | 40 |
41 class QuicSpdyServerStreamPeer : public QuicSpdyServerStream { | 41 class QuicSpdyServerStreamPeer : public QuicSpdyServerStream { |
42 public: | 42 public: |
43 QuicSpdyServerStreamPeer(QuicStreamId stream_id, QuicSession* session) | 43 QuicSpdyServerStreamPeer(QuicStreamId stream_id, QuicSpdySession* session) |
44 : QuicSpdyServerStream(stream_id, session) { | 44 : QuicSpdyServerStream(stream_id, session) {} |
45 } | |
46 | 45 |
47 using QuicSpdyServerStream::SendResponse; | 46 using QuicSpdyServerStream::SendResponse; |
48 using QuicSpdyServerStream::SendErrorResponse; | 47 using QuicSpdyServerStream::SendErrorResponse; |
49 | 48 |
50 SpdyHeaderBlock* mutable_headers() { | 49 SpdyHeaderBlock* mutable_headers() { |
51 return &request_headers_; | 50 return &request_headers_; |
52 } | 51 } |
53 | 52 |
54 static void SendResponse(QuicSpdyServerStream* stream) { | 53 static void SendResponse(QuicSpdyServerStream* stream) { |
55 stream->SendResponse(); | 54 stream->SendResponse(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 const string& StreamBody() { | 112 const string& StreamBody() { |
114 return QuicSpdyServerStreamPeer::body(stream_.get()); | 113 return QuicSpdyServerStreamPeer::body(stream_.get()); |
115 } | 114 } |
116 | 115 |
117 const string& StreamHeadersValue(const string& key) { | 116 const string& StreamHeadersValue(const string& key) { |
118 return (*stream_->mutable_headers())[key]; | 117 return (*stream_->mutable_headers())[key]; |
119 } | 118 } |
120 | 119 |
121 SpdyHeaderBlock response_headers_; | 120 SpdyHeaderBlock response_headers_; |
122 StrictMock<MockConnection>* connection_; | 121 StrictMock<MockConnection>* connection_; |
123 StrictMock<MockSession> session_; | 122 StrictMock<MockQuicSpdySession> session_; |
124 scoped_ptr<QuicSpdyServerStreamPeer> stream_; | 123 scoped_ptr<QuicSpdyServerStreamPeer> stream_; |
125 string headers_string_; | 124 string headers_string_; |
126 string body_; | 125 string body_; |
127 }; | 126 }; |
128 | 127 |
129 QuicConsumedData ConsumeAllData( | 128 QuicConsumedData ConsumeAllData( |
130 QuicStreamId id, | 129 QuicStreamId id, |
131 const IOVector& data, | 130 const IOVector& data, |
132 QuicStreamOffset offset, | 131 QuicStreamOffset offset, |
133 bool fin, | 132 bool fin, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 StringPiece data(arr, arraysize(arr)); | 244 StringPiece data(arr, arraysize(arr)); |
246 QuicStreamFrame frame(stream_->id(), true, 0, data); | 245 QuicStreamFrame frame(stream_->id(), true, 0, data); |
247 // Verify that we don't crash when we get a invalid headers in stream frame. | 246 // Verify that we don't crash when we get a invalid headers in stream frame. |
248 stream_->OnStreamFrame(frame); | 247 stream_->OnStreamFrame(frame); |
249 } | 248 } |
250 | 249 |
251 } // namespace | 250 } // namespace |
252 } // namespace test | 251 } // namespace test |
253 } // namespace tools | 252 } // namespace tools |
254 } // namespace net | 253 } // namespace net |
OLD | NEW |