Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: net/spdy/spdy_websocket_test_util_spdy2.cc

Issue 10832335: WebSocket over SPDY: update test data and expectation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_websocket_test_util_spdy2.h ('k') | net/spdy/spdy_websocket_test_util_spdy3.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/spdy/spdy_websocket_test_util_spdy2.h" 5 #include "net/spdy/spdy_websocket_test_util_spdy2.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 #include "net/spdy/spdy_test_util_spdy2.h" 9 #include "net/spdy/spdy_test_util_spdy2.h"
10 10
11 static const int kDefaultAssociatedStreamId = 0; 11 static const int kDefaultAssociatedStreamId = 0;
12 static const bool kDefaultCompressed = false; 12 static const bool kDefaultCompressed = false;
13 static const char* const kDefaultDataPointer = NULL; 13 static const char* const kDefaultDataPointer = NULL;
14 static const uint32 kDefaultDataLength = 0; 14 static const uint32 kDefaultDataLength = 0;
15 static const char** const kDefaultExtraHeaders = NULL; 15 static const char** const kDefaultExtraHeaders = NULL;
16 static const int kDefaultExtraHeaderCount = 0; 16 static const int kDefaultExtraHeaderCount = 0;
17 17
18 namespace net { 18 namespace net {
19 19
20 namespace test_spdy2 { 20 namespace test_spdy2 {
21 21
22 SpdyFrame* ConstructSpdyWebSocketSynStream(int stream_id,
23 const char* path,
24 const char* host,
25 const char* origin) {
26 const char* const kWebSocketHeaders[] = {
27 "path",
28 path,
29 "host",
30 host,
31 "version",
32 "WebSocket/13",
33 "scheme",
34 "ws",
35 "origin",
36 origin
37 };
38 return ConstructSpdyControlFrame(/*extra_headers*/ NULL,
39 /*extra_header_count*/ 0,
40 /*compressed*/ false,
41 stream_id,
42 HIGHEST,
43 SYN_STREAM,
44 CONTROL_FLAG_NONE,
45 kWebSocketHeaders,
46 arraysize(kWebSocketHeaders));
47 }
48
49 SpdyFrame* ConstructSpdyWebSocketSynReply(int stream_id) {
50 static const char* const kStandardWebSocketHeaders[] = {
51 "status",
52 "101"
53 };
54 return ConstructSpdyControlFrame(NULL,
55 0,
56 false,
57 stream_id,
58 LOWEST,
59 SYN_REPLY,
60 CONTROL_FLAG_NONE,
61 kStandardWebSocketHeaders,
62 arraysize(kStandardWebSocketHeaders));
63 }
64
22 SpdyFrame* ConstructSpdyWebSocketHandshakeRequestFrame( 65 SpdyFrame* ConstructSpdyWebSocketHandshakeRequestFrame(
23 const char* const headers[], 66 const char* const headers[],
24 int header_count, 67 int header_count,
25 SpdyStreamId stream_id, 68 SpdyStreamId stream_id,
26 RequestPriority request_priority) { 69 RequestPriority request_priority) {
27 70
28 // SPDY SYN_STREAM control frame header. 71 // SPDY SYN_STREAM control frame header.
29 const SpdyHeaderInfo kSynStreamHeader = { 72 const SpdyHeaderInfo kSynStreamHeader = {
30 SYN_STREAM, 73 SYN_STREAM,
31 stream_id, 74 stream_id,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 113
71 // Construct SPDY SYN_REPLY control frame. 114 // Construct SPDY SYN_REPLY control frame.
72 return ConstructSpdyPacket( 115 return ConstructSpdyPacket(
73 kSynReplyHeader, 116 kSynReplyHeader,
74 kDefaultExtraHeaders, 117 kDefaultExtraHeaders,
75 kDefaultExtraHeaderCount, 118 kDefaultExtraHeaderCount,
76 headers, 119 headers,
77 header_count); 120 header_count);
78 } 121 }
79 122
123 SpdyFrame* ConstructSpdyWebSocketHeadersFrame(int stream_id,
124 const char* length,
125 bool fin) {
126 static const char* const kHeaders[] = {
127 "opcode",
128 "1", // text frame
129 "length",
130 length,
131 "fin",
132 fin ? "1" : "0"
133 };
134 return ConstructSpdyControlFrame(/*extra_headers*/ NULL,
135 /*extra_header_count*/ 0,
136 /*compression*/ false,
137 stream_id,
138 LOWEST,
139 HEADERS,
140 CONTROL_FLAG_NONE,
141 kHeaders,
142 arraysize(kHeaders));
143 }
144
80 SpdyFrame* ConstructSpdyWebSocketDataFrame( 145 SpdyFrame* ConstructSpdyWebSocketDataFrame(
81 const char* data, 146 const char* data,
82 int len, 147 int len,
83 SpdyStreamId stream_id, 148 SpdyStreamId stream_id,
84 bool fin) { 149 bool fin) {
85 150
86 // Construct SPDY data frame. 151 // Construct SPDY data frame.
87 BufferedSpdyFramer framer(2); 152 BufferedSpdyFramer framer(2);
88 return framer.CreateDataFrame( 153 return framer.CreateDataFrame(
89 stream_id, 154 stream_id,
90 data, 155 data,
91 len, 156 len,
92 fin ? DATA_FLAG_FIN : DATA_FLAG_NONE); 157 fin ? DATA_FLAG_FIN : DATA_FLAG_NONE);
93 } 158 }
94 159
95 } // namespace test_spdy2 160 } // namespace test_spdy2
96 161
97 } // namespace net 162 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_websocket_test_util_spdy2.h ('k') | net/spdy/spdy_websocket_test_util_spdy3.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698