OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 // VMOptions= | 5 // VMOptions= |
6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
9 | 9 |
10 import "dart:async"; | 10 import "dart:async"; |
11 import "dart:convert"; | 11 import "dart:convert"; |
12 import "dart:io"; | 12 import "dart:io"; |
13 import "dart:typed_data"; | 13 import "dart:typed_data"; |
14 import "dart:math"; | 14 import "dart:math"; |
15 | 15 |
16 import "package:async_helper/async_helper.dart"; | 16 import "package:async_helper/async_helper.dart"; |
17 import "package:crypto/crypto.dart"; | 17 import "package:crypto/crypto.dart"; |
18 import "package:expect/expect.dart"; | 18 import "package:expect/expect.dart"; |
19 import "package:path/path.dart"; | 19 import "package:path/path.dart"; |
20 | 20 |
21 const WEB_SOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 21 const WEB_SOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
22 | 22 |
23 const String HOST_NAME = 'localhost'; | 23 const String HOST_NAME = 'localhost'; |
24 | 24 |
25 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 25 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
26 | 26 |
27 SecurityContext serverContext = new SecurityContext() | 27 SecurityContext serverContext = new SecurityContext() |
28 ..useCertificateChain(localFile('certificates/server_chain.pem')) | 28 ..useCertificateChain(localFile('certificates/server_chain.pem')) |
29 ..usePrivateKey(localFile('certificates/server_key.pem'), | 29 ..usePrivateKey(localFile('certificates/server_key.pem'), |
30 password: 'dartdart'); | 30 password: 'dartdart'); |
31 | 31 |
32 class SecurityConfiguration { | 32 class SecurityConfiguration { |
33 final bool secure; | 33 final bool secure; |
34 | 34 |
35 SecurityConfiguration({bool this.secure}); | 35 SecurityConfiguration({bool this.secure}); |
36 | 36 |
37 Future<HttpServer> createServer({int backlog: 0}) => | 37 Future<HttpServer> createServer({int backlog: 0}) => secure |
38 secure ? HttpServer.bindSecure(HOST_NAME, | 38 ? HttpServer.bindSecure(HOST_NAME, 0, serverContext, backlog: backlog) |
39 0, | 39 : HttpServer.bind(HOST_NAME, 0, backlog: backlog); |
40 serverContext, | |
41 backlog: backlog) | |
42 : HttpServer.bind(HOST_NAME, | |
43 0, | |
44 backlog: backlog); | |
45 | 40 |
46 Future<WebSocket> createClient(int port) => | 41 Future<WebSocket> createClient(int port) => |
47 // TODO(whesse): Add client context argument to WebSocket.connect | 42 // TODO(whesse): Add client context argument to WebSocket.connect |
48 WebSocket.connect('${secure ? "wss" : "ws"}://$HOST_NAME:$port/'); | 43 WebSocket.connect('${secure ? "wss" : "ws"}://$HOST_NAME:$port/'); |
49 | 44 |
50 Future<HttpClientResponse> createWebsocket(String url, String headerValue) { | 45 Future<HttpClientResponse> createWebsocket(String url, String headerValue) { |
51 HttpClient _httpClient = new HttpClient(); | 46 HttpClient _httpClient = new HttpClient(); |
52 Uri uri = Uri.parse(url); | 47 Uri uri = Uri.parse(url); |
53 | 48 |
54 Random random = new Random(); | 49 Random random = new Random(); |
(...skipping 25 matching lines...) Expand all Loading... |
80 ..set(HttpHeaders.UPGRADE, "websocket") | 75 ..set(HttpHeaders.UPGRADE, "websocket") |
81 ..set("Sec-WebSocket-Key", nonce) | 76 ..set("Sec-WebSocket-Key", nonce) |
82 ..set("Cache-Control", "no-cache") | 77 ..set("Cache-Control", "no-cache") |
83 ..set("Sec-WebSocket-Version", "13") | 78 ..set("Sec-WebSocket-Version", "13") |
84 ..set("Sec-WebSocket-Extensions", headerValue); | 79 ..set("Sec-WebSocket-Extensions", headerValue); |
85 | 80 |
86 return request.close(); | 81 return request.close(); |
87 }); | 82 }); |
88 } | 83 } |
89 | 84 |
90 void testCompressionSupport({server: false, | 85 void testCompressionSupport( |
91 client: false, | 86 {server: false, client: false, contextTakeover: false}) { |
92 contextTakeover: false}) { | |
93 asyncStart(); | 87 asyncStart(); |
94 | 88 |
95 var clientOptions = new CompressionOptions( | 89 var clientOptions = new CompressionOptions( |
96 enabled: client, | 90 enabled: client, |
97 serverNoContextTakeover: contextTakeover, | 91 serverNoContextTakeover: contextTakeover, |
98 clientNoContextTakeover: contextTakeover); | 92 clientNoContextTakeover: contextTakeover); |
99 var serverOptions = new CompressionOptions( | 93 var serverOptions = new CompressionOptions( |
100 enabled: server, | 94 enabled: server, |
101 serverNoContextTakeover: contextTakeover, | 95 serverNoContextTakeover: contextTakeover, |
102 clientNoContextTakeover: contextTakeover); | 96 clientNoContextTakeover: contextTakeover); |
103 | 97 |
104 createServer().then((server) { | 98 createServer().then((server) { |
105 server.listen((request) { | 99 server.listen((request) { |
106 Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request)); | 100 Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request)); |
107 WebSocketTransformer.upgrade(request, compression: serverOptions) | 101 WebSocketTransformer |
108 .then((webSocket) { | 102 .upgrade(request, compression: serverOptions) |
109 webSocket.listen((message) { | 103 .then((webSocket) { |
110 Expect.equals("Hello World", message); | 104 webSocket.listen((message) { |
| 105 Expect.equals("Hello World", message); |
111 | 106 |
112 webSocket.add(message); | 107 webSocket.add(message); |
113 webSocket.close(); | 108 webSocket.close(); |
114 }); | 109 }); |
115 webSocket.add("Hello World"); | 110 webSocket.add("Hello World"); |
116 }); | 111 }); |
117 }); | 112 }); |
118 | 113 |
119 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; | 114 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; |
120 WebSocket.connect(url, compression: clientOptions).then((websocket) { | 115 WebSocket.connect(url, compression: clientOptions).then((websocket) { |
121 var future = websocket.listen((message) { | 116 var future = websocket.listen((message) { |
122 Expect.equals("Hello World", message); | 117 Expect.equals("Hello World", message); |
123 }).asFuture(); | 118 }).asFuture(); |
124 websocket.add("Hello World"); | 119 websocket.add("Hello World"); |
125 return future; | 120 return future; |
126 }).then((_) { | 121 }).then((_) { |
127 server.close(); | 122 server.close(); |
128 asyncEnd(); | 123 asyncEnd(); |
129 }); | 124 }); |
130 }); | 125 }); |
131 } | 126 } |
132 | 127 |
133 void testContextSupport({CompressionOptions serverOpts, | 128 void testContextSupport( |
134 CompressionOptions clientOpts, | 129 {CompressionOptions serverOpts, |
135 int messages}) { | 130 CompressionOptions clientOpts, |
| 131 int messages}) { |
136 asyncStart(); | 132 asyncStart(); |
137 | 133 |
138 createServer().then((server) { | 134 createServer().then((server) { |
139 server.listen((request) { | 135 server.listen((request) { |
140 Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request)); | 136 Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request)); |
141 WebSocketTransformer.upgrade(request, compression: serverOpts) | 137 WebSocketTransformer |
142 .then((webSocket) { | 138 .upgrade(request, compression: serverOpts) |
143 webSocket.listen((message) { | 139 .then((webSocket) { |
144 Expect.equals("Hello World", message); | 140 webSocket.listen((message) { |
145 webSocket.add(message); | 141 Expect.equals("Hello World", message); |
146 }); | 142 webSocket.add(message); |
| 143 }); |
147 }); | 144 }); |
148 }); | 145 }); |
149 | 146 |
150 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; | 147 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; |
151 WebSocket.connect(url, compression: clientOpts).then((websocket) { | 148 WebSocket.connect(url, compression: clientOpts).then((websocket) { |
152 var i = 1; | 149 var i = 1; |
153 websocket.listen((message) { | 150 websocket.listen((message) { |
154 Expect.equals("Hello World", message); | 151 Expect.equals("Hello World", message); |
155 if (i == messages) { | 152 if (i == messages) { |
156 websocket.close(); | 153 websocket.close(); |
(...skipping 14 matching lines...) Expand all Loading... |
171 asyncStart(); | 168 asyncStart(); |
172 createServer().then((server) { | 169 createServer().then((server) { |
173 server.listen((request) { | 170 server.listen((request) { |
174 Expect.equals('Upgrade', request.headers.value(HttpHeaders.CONNECTION)); | 171 Expect.equals('Upgrade', request.headers.value(HttpHeaders.CONNECTION)); |
175 Expect.equals('websocket', request.headers.value(HttpHeaders.UPGRADE)); | 172 Expect.equals('websocket', request.headers.value(HttpHeaders.UPGRADE)); |
176 | 173 |
177 var key = request.headers.value('Sec-WebSocket-Key'); | 174 var key = request.headers.value('Sec-WebSocket-Key'); |
178 var digest = sha1.convert("$key$WEB_SOCKET_GUID".codeUnits); | 175 var digest = sha1.convert("$key$WEB_SOCKET_GUID".codeUnits); |
179 var accept = BASE64.encode(digest.bytes); | 176 var accept = BASE64.encode(digest.bytes); |
180 request.response | 177 request.response |
181 ..statusCode = HttpStatus.SWITCHING_PROTOCOLS | 178 ..statusCode = HttpStatus.SWITCHING_PROTOCOLS |
182 ..headers.add(HttpHeaders.CONNECTION, "Upgrade") | 179 ..headers.add(HttpHeaders.CONNECTION, "Upgrade") |
183 ..headers.add(HttpHeaders.UPGRADE, "websocket") | 180 ..headers.add(HttpHeaders.UPGRADE, "websocket") |
184 ..headers.add("Sec-WebSocket-Accept", accept) | 181 ..headers.add("Sec-WebSocket-Accept", accept) |
185 ..headers.add("Sec-WebSocket-Extensions", | 182 ..headers.add( |
| 183 "Sec-WebSocket-Extensions", |
186 "permessage-deflate;" | 184 "permessage-deflate;" |
187 // Test quoted values and space padded = | 185 // Test quoted values and space padded = |
188 'server_max_window_bits="10"; client_max_window_bits = 12' | 186 'server_max_window_bits="10"; client_max_window_bits = 12' |
189 'client_no_context_takeover; server_no_context_takeover'); | 187 'client_no_context_takeover; server_no_context_takeover'); |
190 request.response.contentLength = 0; | 188 request.response.contentLength = 0; |
191 request.response.detachSocket().then((socket) { | 189 request.response.detachSocket().then((socket) { |
192 return new WebSocket.fromUpgradedSocket(socket, serverSide: true); | 190 return new WebSocket.fromUpgradedSocket(socket, serverSide: true); |
193 }).then((websocket) { | 191 }).then((websocket) { |
194 websocket.add("Hello"); | 192 websocket.add("Hello"); |
195 websocket.close(); | 193 websocket.close(); |
196 asyncEnd(); | 194 asyncEnd(); |
197 }); | 195 }); |
198 }); | 196 }); |
199 | 197 |
200 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; | 198 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; |
201 | 199 |
202 WebSocket.connect(url).then((websocket) { | 200 WebSocket.connect(url).then((websocket) { |
203 return websocket.listen((message) { | 201 return websocket.listen((message) { |
204 Expect.equals("Hello", message); | 202 Expect.equals("Hello", message); |
205 websocket.close(); | 203 websocket.close(); |
206 }).asFuture(); | 204 }).asFuture(); |
207 }).then((_) => server.close()); | 205 }).then((_) => server.close()); |
208 }); | 206 }); |
209 } | 207 } |
210 | 208 |
211 void testReturnHeaders(String headerValue, String expected, { | 209 void testReturnHeaders(String headerValue, String expected, |
212 CompressionOptions serverCompression: CompressionOptions.DEFAULT}) { | 210 {CompressionOptions serverCompression: CompressionOptions.DEFAULT}) { |
213 asyncStart(); | 211 asyncStart(); |
214 createServer().then((server) { | 212 createServer().then((server) { |
215 server.listen((request) { | 213 server.listen((request) { |
216 // Stuff | 214 // Stuff |
217 Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request)); | 215 Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request)); |
218 WebSocketTransformer.upgrade(request, compression: serverCompression) | 216 WebSocketTransformer |
219 .then((webSocket) { | 217 .upgrade(request, compression: serverCompression) |
220 webSocket.listen((message) { | 218 .then((webSocket) { |
221 Expect.equals("Hello World", message); | 219 webSocket.listen((message) { |
| 220 Expect.equals("Hello World", message); |
222 | 221 |
223 webSocket.add(message); | 222 webSocket.add(message); |
224 webSocket.close(); | 223 webSocket.close(); |
225 }); | 224 }); |
226 }); | 225 }); |
227 }); | 226 }); |
228 | 227 |
229 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; | 228 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; |
230 createWebsocket(url, headerValue) | 229 createWebsocket(url, headerValue).then((HttpClientResponse response) { |
231 .then((HttpClientResponse response) { | 230 Expect.equals(response.statusCode, HttpStatus.SWITCHING_PROTOCOLS); |
232 Expect.equals(response.statusCode, HttpStatus.SWITCHING_PROTOCOLS); | 231 print(response.headers.value('Sec-WebSocket-Extensions')); |
233 print(response.headers.value('Sec-WebSocket-Extensions')); | 232 Expect.equals( |
234 Expect.equals(response.headers.value("Sec-WebSocket-Extensions"), | 233 response.headers.value("Sec-WebSocket-Extensions"), expected); |
235 expected); | |
236 | 234 |
237 String accept = response.headers.value("Sec-WebSocket-Accept"); | 235 String accept = response.headers.value("Sec-WebSocket-Accept"); |
238 Expect.isNotNull(accept); | 236 Expect.isNotNull(accept); |
239 | 237 |
240 var protocol = response.headers.value('Sec-WebSocket-Protocol'); | 238 var protocol = response.headers.value('Sec-WebSocket-Protocol'); |
241 return response.detachSocket().then((socket) => | 239 return response.detachSocket().then((socket) => |
242 new WebSocket.fromUpgradedSocket( | 240 new WebSocket.fromUpgradedSocket(socket, |
243 socket, protocol: protocol, serverSide: false)); | 241 protocol: protocol, serverSide: false)); |
244 }).then((websocket) { | 242 }).then((websocket) { |
245 var future = websocket.listen((message) { | 243 var future = websocket.listen((message) { |
246 Expect.equals("Hello", message); | 244 Expect.equals("Hello", message); |
247 websocket.close(); | 245 websocket.close(); |
248 }).asFuture(); | 246 }).asFuture(); |
249 websocket.add("Hello World"); | 247 websocket.add("Hello World"); |
250 return future; | 248 return future; |
251 }).then((_) { | 249 }).then((_) { |
252 server.close(); | 250 server.close(); |
253 asyncEnd(); | 251 asyncEnd(); |
254 }); | 252 }); |
255 }); // End createServer | 253 }); // End createServer |
256 } | 254 } |
257 | 255 |
258 void testClientRequestHeaders(CompressionOptions compression) { | 256 void testClientRequestHeaders(CompressionOptions compression) { |
259 asyncStart(); | 257 asyncStart(); |
260 createServer().then((server) { | 258 createServer().then((server) { |
261 server.listen((request) { | 259 server.listen((request) { |
262 var extensionHeader = request.headers.value('Sec-WebSocket-Extensions'); | 260 var extensionHeader = request.headers.value('Sec-WebSocket-Extensions'); |
263 var hv = HeaderValue.parse(extensionHeader); | 261 var hv = HeaderValue.parse(extensionHeader); |
264 Expect.equals(compression.serverNoContextTakeover, | 262 Expect.equals(compression.serverNoContextTakeover, |
265 hv.parameters.containsKey('server_no_context_takeover')); | 263 hv.parameters.containsKey('server_no_context_takeover')); |
266 Expect.equals(compression.clientNoContextTakeover, | 264 Expect.equals(compression.clientNoContextTakeover, |
267 hv.parameters.containsKey('client_no_context_takeover')); | 265 hv.parameters.containsKey('client_no_context_takeover')); |
268 Expect.equals(compression.serverMaxWindowBits?.toString(), | 266 Expect.equals(compression.serverMaxWindowBits?.toString(), |
269 hv.parameters['server_max_window_bits']); | 267 hv.parameters['server_max_window_bits']); |
270 Expect.equals(compression.clientMaxWindowBits?.toString(), | 268 Expect.equals(compression.clientMaxWindowBits?.toString(), |
271 hv.parameters['client_max_window_bits']); | 269 hv.parameters['client_max_window_bits']); |
272 | 270 |
273 WebSocketTransformer.upgrade(request).then((webSocket) { | 271 WebSocketTransformer.upgrade(request).then((webSocket) { |
274 webSocket.listen((message) { | 272 webSocket.listen((message) { |
275 Expect.equals('Hello World', message); | 273 Expect.equals('Hello World', message); |
276 | 274 |
277 webSocket.add(message); | 275 webSocket.add(message); |
278 webSocket.close(); | 276 webSocket.close(); |
279 }); | 277 }); |
280 }); | 278 }); |
281 }); | 279 }); |
282 | 280 |
283 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; | 281 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; |
284 | 282 |
285 WebSocket.connect(url, compression: compression).then((websocket) { | 283 WebSocket.connect(url, compression: compression).then((websocket) { |
286 var future = websocket.listen((message) { | 284 var future = websocket.listen((message) { |
287 Expect.equals('Hello World', message); | 285 Expect.equals('Hello World', message); |
288 websocket.close(); | 286 websocket.close(); |
289 }).asFuture(); | 287 }).asFuture(); |
(...skipping 14 matching lines...) Expand all Loading... |
304 // compression and context takeover. | 302 // compression and context takeover. |
305 testCompressionSupport(server: true, client: true, contextTakeover: true); | 303 testCompressionSupport(server: true, client: true, contextTakeover: true); |
306 // Compression on client but not server. No take over | 304 // Compression on client but not server. No take over |
307 testCompressionSupport(client: true); | 305 testCompressionSupport(client: true); |
308 // Compression on server but not client. | 306 // Compression on server but not client. |
309 testCompressionSupport(server: true); | 307 testCompressionSupport(server: true); |
310 | 308 |
311 // Test Multiple messages with various context takeover configurations. | 309 // Test Multiple messages with various context takeover configurations. |
312 // no context takeover on the server. | 310 // no context takeover on the server. |
313 var serverComp = new CompressionOptions(serverNoContextTakeover: true); | 311 var serverComp = new CompressionOptions(serverNoContextTakeover: true); |
314 testContextSupport(serverOpts: serverComp, | 312 testContextSupport( |
315 clientOpts: serverComp, | 313 serverOpts: serverComp, clientOpts: serverComp, messages: 5); |
316 messages: 5); | |
317 // no contexttakeover on the client. | 314 // no contexttakeover on the client. |
318 var clientComp = new CompressionOptions(clientNoContextTakeover: true); | 315 var clientComp = new CompressionOptions(clientNoContextTakeover: true); |
319 testContextSupport(serverOpts: clientComp, | 316 testContextSupport( |
320 clientOpts: clientComp, | 317 serverOpts: clientComp, clientOpts: clientComp, messages: 5); |
321 messages: 5); | |
322 // no context takeover enabled for both. | 318 // no context takeover enabled for both. |
323 var compression = new CompressionOptions(serverNoContextTakeover: true, | 319 var compression = new CompressionOptions( |
324 clientNoContextTakeover: true); | 320 serverNoContextTakeover: true, clientNoContextTakeover: true); |
325 testContextSupport(serverOpts: compression, | 321 testContextSupport( |
326 clientOpts: compression, | 322 serverOpts: compression, clientOpts: compression, messages: 5); |
327 messages: 5); | |
328 // no context take over for opposing configurations. | 323 // no context take over for opposing configurations. |
329 testContextSupport(serverOpts: serverComp, | 324 testContextSupport( |
330 clientOpts: clientComp, | 325 serverOpts: serverComp, clientOpts: clientComp, messages: 5); |
331 messages: 5); | 326 testContextSupport( |
332 testContextSupport(serverOpts: clientComp, | 327 serverOpts: clientComp, clientOpts: serverComp, messages: 5); |
333 clientOpts: serverComp, | |
334 messages: 5); | |
335 | 328 |
336 testCompressionHeaders(); | 329 testCompressionHeaders(); |
337 // Chrome headers | 330 // Chrome headers |
338 testReturnHeaders('permessage-deflate; client_max_window_bits', | 331 testReturnHeaders('permessage-deflate; client_max_window_bits', |
339 "permessage-deflate; client_max_window_bits=15"); | 332 "permessage-deflate; client_max_window_bits=15"); |
340 // Firefox headers | 333 // Firefox headers |
341 testReturnHeaders('permessage-deflate', | 334 testReturnHeaders( |
342 "permessage-deflate; client_max_window_bits=15"); | 335 'permessage-deflate', "permessage-deflate; client_max_window_bits=15"); |
343 // Ensure max_window_bits resize appropriately. | 336 // Ensure max_window_bits resize appropriately. |
344 testReturnHeaders('permessage-deflate; server_max_window_bits=10', | 337 testReturnHeaders( |
345 "permessage-deflate;" | 338 'permessage-deflate; server_max_window_bits=10', |
346 " server_max_window_bits=10;" | 339 "permessage-deflate;" |
347 " client_max_window_bits=10"); | 340 " server_max_window_bits=10;" |
| 341 " client_max_window_bits=10"); |
348 // Don't provider context takeover if requested but not enabled. | 342 // Don't provider context takeover if requested but not enabled. |
349 // Default is not enabled. | 343 // Default is not enabled. |
350 testReturnHeaders('permessage-deflate; client_max_window_bits;' | 344 testReturnHeaders( |
351 'client_no_context_takeover', | 345 'permessage-deflate; client_max_window_bits;' |
352 'permessage-deflate; client_max_window_bits=15'); | 346 'client_no_context_takeover', |
| 347 'permessage-deflate; client_max_window_bits=15'); |
353 // Enable context Takeover and provide if requested. | 348 // Enable context Takeover and provide if requested. |
354 compression = new CompressionOptions(clientNoContextTakeover: true, | 349 compression = new CompressionOptions( |
355 serverNoContextTakeover: true); | 350 clientNoContextTakeover: true, serverNoContextTakeover: true); |
356 testReturnHeaders('permessage-deflate; client_max_window_bits; ' | 351 testReturnHeaders( |
357 'client_no_context_takeover', | 352 'permessage-deflate; client_max_window_bits; ' |
358 'permessage-deflate; client_no_context_takeover; ' | 353 'client_no_context_takeover', |
359 'client_max_window_bits=15', | 354 'permessage-deflate; client_no_context_takeover; ' |
360 serverCompression: compression); | 355 'client_max_window_bits=15', |
| 356 serverCompression: compression); |
361 // Enable context takeover and don't provide if not requested | 357 // Enable context takeover and don't provide if not requested |
362 compression = new CompressionOptions(clientNoContextTakeover: true, | 358 compression = new CompressionOptions( |
363 serverNoContextTakeover: true); | 359 clientNoContextTakeover: true, serverNoContextTakeover: true); |
364 testReturnHeaders('permessage-deflate; client_max_window_bits; ', | 360 testReturnHeaders('permessage-deflate; client_max_window_bits; ', |
365 'permessage-deflate; client_max_window_bits=15', | 361 'permessage-deflate; client_max_window_bits=15', |
366 serverCompression: compression); | 362 serverCompression: compression); |
367 | 363 |
368 compression = CompressionOptions.DEFAULT; | 364 compression = CompressionOptions.DEFAULT; |
369 testClientRequestHeaders(compression); | 365 testClientRequestHeaders(compression); |
370 compression = new CompressionOptions(clientNoContextTakeover: true, | 366 compression = new CompressionOptions( |
371 serverNoContextTakeover: true); | 367 clientNoContextTakeover: true, serverNoContextTakeover: true); |
372 testClientRequestHeaders(compression); | 368 testClientRequestHeaders(compression); |
373 compression = new CompressionOptions(clientNoContextTakeover: true, | 369 compression = new CompressionOptions( |
| 370 clientNoContextTakeover: true, |
374 serverNoContextTakeover: true, | 371 serverNoContextTakeover: true, |
375 clientMaxWindowBits: 8, | 372 clientMaxWindowBits: 8, |
376 serverMaxWindowBits: 8); | 373 serverMaxWindowBits: 8); |
377 testClientRequestHeaders(compression); | 374 testClientRequestHeaders(compression); |
378 } | 375 } |
379 } | 376 } |
380 | 377 |
381 main() { | 378 main() { |
382 new SecurityConfiguration(secure: false).runTests(); | 379 new SecurityConfiguration(secure: false).runTests(); |
383 // TODO(whesse): Make WebSocket.connect() take an optional context: parameter. | 380 // TODO(whesse): Make WebSocket.connect() take an optional context: parameter. |
384 // new SecurityConfiguration(secure: true).runTests(); | 381 // new SecurityConfiguration(secure: true).runTests(); |
385 } | 382 } |
OLD | NEW |