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/spdy/spdy_websocket_test_util.h" | 5 #include "net/spdy/spdy_websocket_test_util.h" |
6 | 6 |
7 #include "net/spdy/buffered_spdy_framer.h" | 7 #include "net/spdy/buffered_spdy_framer.h" |
8 #include "net/spdy/spdy_http_utils.h" | 8 #include "net/spdy/spdy_http_utils.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 /*compressed*/ false, | 45 /*compressed*/ false, |
46 stream_id, | 46 stream_id, |
47 HIGHEST, | 47 HIGHEST, |
48 SYN_STREAM, | 48 SYN_STREAM, |
49 CONTROL_FLAG_NONE, | 49 CONTROL_FLAG_NONE, |
50 0); | 50 0); |
51 } | 51 } |
52 | 52 |
53 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdyWebSocketSynReply( | 53 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdyWebSocketSynReply( |
54 int stream_id) { | 54 int stream_id) { |
55 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock()); | 55 SpdyHeaderBlock block; |
56 SetHeader("status", "101", headers.get()); | 56 SetHeader("status", "101", &block); |
57 return spdy_util_.ConstructSpdyControlFrame(headers.Pass(), | 57 return spdy_util_.ConstructSpdyReply(stream_id, block); |
58 false, | |
59 stream_id, | |
60 LOWEST, | |
61 SYN_REPLY, | |
62 CONTROL_FLAG_NONE, | |
63 0); | |
64 } | 58 } |
65 | 59 |
66 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdyWebSocketHandshakeRequestFrame( | 60 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdyWebSocketHandshakeRequestFrame( |
67 scoped_ptr<SpdyHeaderBlock> headers, | 61 scoped_ptr<SpdyHeaderBlock> headers, |
68 SpdyStreamId stream_id, | 62 SpdyStreamId stream_id, |
69 RequestPriority request_priority) { | 63 RequestPriority request_priority) { |
70 // SPDY SYN_STREAM control frame header. | 64 // SPDY SYN_STREAM control frame header. |
71 const SpdyHeaderInfo kSynStreamHeader = { | 65 const SpdyHeaderInfo kSynStreamHeader = { |
72 SYN_STREAM, | 66 SYN_STREAM, |
73 stream_id, | 67 stream_id, |
(...skipping 11 matching lines...) Expand all Loading... |
85 // Construct SPDY SYN_STREAM control frame. | 79 // Construct SPDY SYN_STREAM control frame. |
86 return spdy_util_.ConstructSpdyFrame( | 80 return spdy_util_.ConstructSpdyFrame( |
87 kSynStreamHeader, | 81 kSynStreamHeader, |
88 headers.Pass()); | 82 headers.Pass()); |
89 } | 83 } |
90 | 84 |
91 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdyWebSocketHandshakeResponseFrame( | 85 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdyWebSocketHandshakeResponseFrame( |
92 scoped_ptr<SpdyHeaderBlock> headers, | 86 scoped_ptr<SpdyHeaderBlock> headers, |
93 SpdyStreamId stream_id, | 87 SpdyStreamId stream_id, |
94 RequestPriority request_priority) { | 88 RequestPriority request_priority) { |
95 // SPDY SYN_REPLY control frame header. | 89 return spdy_util_.ConstructSpdyReply(stream_id, *headers); |
96 const SpdyHeaderInfo kSynReplyHeader = { | |
97 SYN_REPLY, | |
98 stream_id, | |
99 kDefaultAssociatedStreamId, | |
100 ConvertRequestPriorityToSpdyPriority(request_priority, SPDY2), | |
101 kSpdyCredentialSlotUnused, | |
102 CONTROL_FLAG_NONE, | |
103 kDefaultCompressed, | |
104 RST_STREAM_INVALID, | |
105 kDefaultDataPointer, | |
106 kDefaultDataLength, | |
107 DATA_FLAG_NONE | |
108 }; | |
109 | |
110 // Construct SPDY SYN_REPLY control frame. | |
111 return spdy_util_.ConstructSpdyFrame( | |
112 kSynReplyHeader, | |
113 headers.Pass()); | |
114 } | 90 } |
115 | 91 |
116 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdyWebSocketHeadersFrame( | 92 SpdyFrame* SpdyWebSocketTestUtil::ConstructSpdyWebSocketHeadersFrame( |
117 int stream_id, | 93 int stream_id, |
118 const char* length, | 94 const char* length, |
119 bool fin) { | 95 bool fin) { |
120 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock()); | 96 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock()); |
121 SetHeader("opcode", "1", headers.get()); // text frame | 97 SetHeader("opcode", "1", headers.get()); // text frame |
122 SetHeader("length", length, headers.get()); | 98 SetHeader("length", length, headers.get()); |
123 SetHeader("fin", fin ? "1" : "0", headers.get()); | 99 SetHeader("fin", fin ? "1" : "0", headers.get()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 SpdyMajorVersion SpdyWebSocketTestUtil::spdy_version() const { | 133 SpdyMajorVersion SpdyWebSocketTestUtil::spdy_version() const { |
158 return spdy_util_.spdy_version(); | 134 return spdy_util_.spdy_version(); |
159 } | 135 } |
160 | 136 |
161 std::string SpdyWebSocketTestUtil::GetHeaderKey( | 137 std::string SpdyWebSocketTestUtil::GetHeaderKey( |
162 const std::string& key) const { | 138 const std::string& key) const { |
163 return (spdy_util_.is_spdy2() ? "" : ":") + key; | 139 return (spdy_util_.is_spdy2() ? "" : ":") + key; |
164 } | 140 } |
165 | 141 |
166 } // namespace net | 142 } // namespace net |
OLD | NEW |