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

Side by Side Diff: pkg/shelf_web_socket/test/web_socket_test.dart

Issue 810133002: Fix shelf_web_socket's Connection handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | « pkg/shelf_web_socket/pubspec.yaml ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library shelf_web_socket.web_socket_test; 5 library shelf_web_socket.web_socket_test;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:http/http.dart' as http; 9 import 'package:http/http.dart' as http;
10 import 'package:shelf/shelf_io.dart' as shelf_io; 10 import 'package:shelf/shelf_io.dart' as shelf_io;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 expect(http.get(url, headers: headers), hasStatus(101)); 98 expect(http.get(url, headers: headers), hasStatus(101));
99 }); 99 });
100 100
101 test("ignores the case of the server origin", () { 101 test("ignores the case of the server origin", () {
102 var headers = _handshakeHeaders; 102 var headers = _handshakeHeaders;
103 headers['Origin'] = 'google.com'; 103 headers['Origin'] = 'google.com';
104 expect(http.get(url, headers: headers), hasStatus(101)); 104 expect(http.get(url, headers: headers), hasStatus(101));
105 }); 105 });
106 }); 106 });
107 107
108 // Regression test for issue 21894.
109 test("allows a Connection header with multiple values", () {
110 return shelf_io.serve(webSocketHandler((webSocket) {
111 webSocket.close();
112 }), "localhost", 0).then((server) {
113 var url = 'http://localhost:${server.port}/';
114
115 var headers = _handshakeHeaders;
116 headers['Connection'] = 'Other-Token, Upgrade';
117 expect(http.get(url, headers: headers).whenComplete(server.close),
118 hasStatus(101));
119 });
120 });
121
108 group("HTTP errors", () { 122 group("HTTP errors", () {
109 var server; 123 var server;
110 var url; 124 var url;
111 setUp(() { 125 setUp(() {
112 return shelf_io.serve(webSocketHandler((_) { 126 return shelf_io.serve(webSocketHandler((_) {
113 fail("should not create a WebSocket"); 127 fail("should not create a WebSocket");
114 }), "localhost", 0).then((server_) { 128 }), "localhost", 0).then((server_) {
115 server = server_; 129 server = server_;
116 url = 'http://localhost:${server.port}/'; 130 url = 'http://localhost:${server.port}/';
117 }); 131 });
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 expect(() => webSocketHandler((_) => null, protocols: ['foo']), 172 expect(() => webSocketHandler((_) => null, protocols: ['foo']),
159 throwsArgumentError); 173 throwsArgumentError);
160 }); 174 });
161 } 175 }
162 176
163 Matcher hasStatus(int status) => completion(predicate((response) { 177 Matcher hasStatus(int status) => completion(predicate((response) {
164 expect(response, new isInstanceOf<http.Response>()); 178 expect(response, new isInstanceOf<http.Response>());
165 expect(response.statusCode, equals(status)); 179 expect(response.statusCode, equals(status));
166 return true; 180 return true;
167 })); 181 }));
OLDNEW
« no previous file with comments | « pkg/shelf_web_socket/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698