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/test_tools/quic_test_packet_maker.h" | 5 #include "net/quic/test_tools/quic_test_packet_maker.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "net/quic/quic_framer.h" | 9 #include "net/quic/quic_framer.h" |
10 #include "net/quic/quic_http_utils.h" | 10 #include "net/quic/quic_http_utils.h" |
11 #include "net/quic/quic_utils.h" | 11 #include "net/quic/quic_utils.h" |
12 #include "net/quic/test_tools/quic_test_utils.h" | 12 #include "net/quic/test_tools/quic_test_utils.h" |
13 | 13 |
14 using std::make_pair; | 14 using std::make_pair; |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 namespace test { | 17 namespace test { |
18 | 18 |
19 QuicTestPacketMaker::QuicTestPacketMaker(QuicVersion version, | 19 QuicTestPacketMaker::QuicTestPacketMaker(QuicVersion version, |
20 QuicConnectionId connection_id, | 20 QuicConnectionId connection_id, |
21 MockClock* clock) | 21 MockClock* clock, |
| 22 const std::string& host) |
22 : version_(version), | 23 : version_(version), |
23 connection_id_(connection_id), | 24 connection_id_(connection_id), |
24 clock_(clock), | 25 clock_(clock), |
| 26 host_(host), |
25 spdy_request_framer_(SPDY4), | 27 spdy_request_framer_(SPDY4), |
26 spdy_response_framer_(SPDY4) { | 28 spdy_response_framer_(SPDY4) { |
27 } | 29 } |
28 | 30 |
29 QuicTestPacketMaker::~QuicTestPacketMaker() { | 31 QuicTestPacketMaker::~QuicTestPacketMaker() { |
30 } | 32 } |
31 | 33 |
| 34 void QuicTestPacketMaker::set_hostname(const std::string& host) { |
| 35 host_.assign(host); |
| 36 } |
| 37 |
32 scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeRstPacket( | 38 scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeRstPacket( |
33 QuicPacketSequenceNumber num, | 39 QuicPacketSequenceNumber num, |
34 bool include_version, | 40 bool include_version, |
35 QuicStreamId stream_id, | 41 QuicStreamId stream_id, |
36 QuicRstStreamErrorCode error_code) { | 42 QuicRstStreamErrorCode error_code) { |
37 QuicPacketHeader header; | 43 QuicPacketHeader header; |
38 header.public_header.connection_id = connection_id_; | 44 header.public_header.connection_id = connection_id_; |
39 header.public_header.reset_flag = false; | 45 header.public_header.reset_flag = false; |
40 header.public_header.version_flag = include_version; | 46 header.public_header.version_flag = include_version; |
41 header.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER; | 47 header.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 return MakePacket(header_, QuicFrame(&frame)); | 225 return MakePacket(header_, QuicFrame(&frame)); |
220 } | 226 } |
221 | 227 |
222 SpdyHeaderBlock QuicTestPacketMaker::GetRequestHeaders( | 228 SpdyHeaderBlock QuicTestPacketMaker::GetRequestHeaders( |
223 const std::string& method, | 229 const std::string& method, |
224 const std::string& scheme, | 230 const std::string& scheme, |
225 const std::string& path) { | 231 const std::string& path) { |
226 SpdyHeaderBlock headers; | 232 SpdyHeaderBlock headers; |
227 headers[":method"] = method; | 233 headers[":method"] = method; |
228 if (version_ <= QUIC_VERSION_24) { | 234 if (version_ <= QUIC_VERSION_24) { |
229 headers[":host"] = "www.google.com"; | 235 headers[":host"] = host_; |
230 } else { | 236 } else { |
231 headers[":authority"] = "www.google.com"; | 237 headers[":authority"] = host_; |
232 } | 238 } |
233 headers[":path"] = path; | 239 headers[":path"] = path; |
234 headers[":scheme"] = scheme; | 240 headers[":scheme"] = scheme; |
235 if (version_ <= QUIC_VERSION_24) { | 241 if (version_ <= QUIC_VERSION_24) { |
236 headers[":version"] = "HTTP/1.1"; | 242 headers[":version"] = "HTTP/1.1"; |
237 } | 243 } |
238 return headers; | 244 return headers; |
239 } | 245 } |
240 | 246 |
241 SpdyHeaderBlock QuicTestPacketMaker::GetResponseHeaders( | 247 SpdyHeaderBlock QuicTestPacketMaker::GetResponseHeaders( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 header_.public_header.version_flag = should_include_version; | 280 header_.public_header.version_flag = should_include_version; |
275 header_.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER; | 281 header_.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER; |
276 header_.packet_sequence_number = sequence_number; | 282 header_.packet_sequence_number = sequence_number; |
277 header_.fec_group = 0; | 283 header_.fec_group = 0; |
278 header_.entropy_flag = false; | 284 header_.entropy_flag = false; |
279 header_.fec_flag = false; | 285 header_.fec_flag = false; |
280 } | 286 } |
281 | 287 |
282 } // namespace test | 288 } // namespace test |
283 } // namespace net | 289 } // namespace net |
OLD | NEW |