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

Side by Side Diff: tests/standalone/io/web_socket_ping_test.dart

Issue 2911903002: Use relative URIs for core library part-of statements. (Closed)
Patch Set: Fix warnings in web-sockets tests, typo in fasta. Created 3 years, 5 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
« no previous file with comments | « tests/standalone/io/web_socket_error_test.dart ('k') | no next file » | 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) 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 library dart.io; 10 library dart.io;
11 11
12 import "package:expect/expect.dart"; 12 import "package:expect/expect.dart";
13 import "dart:async"; 13 import "dart:async";
14 import "dart:convert" show BASE64;
14 import "dart:io"; 15 import "dart:io";
15 import "dart:math"; 16 import "dart:math";
16 17
17 part "../../../sdk/lib/io/crypto.dart"; 18 import "hash_utils.dart";
18 19
19 const String webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; 20 const String webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
20 21
21 void testPing(int totalConnections) { 22 void testPing(int totalConnections) {
22 HttpServer.bind('localhost', 0).then((server) { 23 HttpServer.bind('localhost', 0).then((server) {
23 int closed = 0; 24 int closed = 0;
24 server.listen((request) { 25 server.listen((request) {
25 var response = request.response; 26 var response = request.response;
26 response.statusCode = HttpStatus.SWITCHING_PROTOCOLS; 27 response.statusCode = HttpStatus.SWITCHING_PROTOCOLS;
27 response.headers.set(HttpHeaders.CONNECTION, "upgrade"); 28 response.headers.set(HttpHeaders.CONNECTION, "upgrade");
28 response.headers.set(HttpHeaders.UPGRADE, "websocket"); 29 response.headers.set(HttpHeaders.UPGRADE, "websocket");
29 String key = request.headers.value("Sec-WebSocket-Key"); 30 String key = request.headers.value("Sec-WebSocket-Key");
30 _SHA1 sha1 = new _SHA1(); 31 var sha1 = new SHA1();
31 sha1.add("$key$webSocketGUID".codeUnits); 32 sha1.add("$key$webSocketGUID".codeUnits);
32 String accept = _CryptoUtils.bytesToBase64(sha1.close()); 33 String accept = BASE64.encode(sha1.close());
33 response.headers.add("Sec-WebSocket-Accept", accept); 34 response.headers.add("Sec-WebSocket-Accept", accept);
34 response.headers.contentLength = 0; 35 response.headers.contentLength = 0;
35 response.detachSocket().then((socket) { 36 response.detachSocket().then((socket) {
36 socket.drain().then((_) { 37 socket.drain().then((_) {
37 socket.close(); 38 socket.close();
38 closed++; 39 closed++;
39 if (closed == totalConnections) { 40 if (closed == totalConnections) {
40 server.close(); 41 server.close();
41 } 42 }
42 }); 43 });
43 }); 44 });
44 }); 45 });
45 46
46 for (int i = 0; i < totalConnections; i++) { 47 for (int i = 0; i < totalConnections; i++) {
47 WebSocket.connect('ws://localhost:${server.port}').then((webSocket) { 48 WebSocket.connect('ws://localhost:${server.port}').then((webSocket) {
48 webSocket.pingInterval = const Duration(milliseconds: 100); 49 webSocket.pingInterval = const Duration(milliseconds: 100);
49 webSocket.drain(); 50 webSocket.drain();
50 }); 51 });
51 } 52 }
52 }); 53 });
53 } 54 }
54 55
55 void main() { 56 void main() {
56 testPing(10); 57 testPing(10);
57 } 58 }
OLDNEW
« no previous file with comments | « tests/standalone/io/web_socket_error_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698