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

Side by Side Diff: tools/testing/dart/http_server.dart

Issue 17078007: Update checked in binary to version 0.5.19.0 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | « tools/testing/dart/browser_controller.dart ('k') | tools/testing/dart/multitest.dart » ('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) 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 library http_server; 5 library http_server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:uri';
11 import 'test_suite.dart'; // For TestUtils. 10 import 'test_suite.dart'; // For TestUtils.
12 // TODO(efortuna): Rewrite to not use the args library and simply take an 11 // TODO(efortuna): Rewrite to not use the args library and simply take an
13 // expected number of arguments, so test.dart doesn't rely on the args library? 12 // expected number of arguments, so test.dart doesn't rely on the args library?
14 // See discussion on https://codereview.chromium.org/11931025/. 13 // See discussion on https://codereview.chromium.org/11931025/.
15 import 'vendored_pkg/args/args.dart'; 14 import 'vendored_pkg/args/args.dart';
16 import 'utils.dart'; 15 import 'utils.dart';
17 16
18 17
19 /// Interface of the HTTP server: 18 /// Interface of the HTTP server:
20 /// 19 ///
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 response.headers.set("Access-Control-Allow-Origin", "*"); 201 response.headers.set("Access-Control-Allow-Origin", "*");
203 request.pipe(response).catchError((e) { 202 request.pipe(response).catchError((e) {
204 DebugLogger.warning( 203 DebugLogger.warning(
205 'HttpServer: error while closing the response stream', e); 204 'HttpServer: error while closing the response stream', e);
206 }); 205 });
207 } 206 }
208 207
209 void _handleWebSocketRequest(HttpRequest request) { 208 void _handleWebSocketRequest(HttpRequest request) {
210 WebSocketTransformer.upgrade(request).then((websocket) { 209 WebSocketTransformer.upgrade(request).then((websocket) {
211 websocket.listen((data) { 210 websocket.listen((data) {
212 websocket.send(data); 211 websocket.add(data);
213 websocket.close(); 212 websocket.close();
214 }, onError: (e) { 213 }, onError: (e) {
215 DebugLogger.warning('HttpServer: error while echoing to WebSocket', e); 214 DebugLogger.warning('HttpServer: error while echoing to WebSocket', e);
216 }); 215 });
217 }).catchError((e) { 216 }).catchError((e) {
218 DebugLogger.warning( 217 DebugLogger.warning(
219 'HttpServer: error while transforming to WebSocket', e); 218 'HttpServer: error while transforming to WebSocket', e);
220 }); 219 });
221 } 220 }
222 221
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 306
308 void _sendFileContent(HttpRequest request, 307 void _sendFileContent(HttpRequest request,
309 HttpResponse response, 308 HttpResponse response,
310 int allowedPort, 309 int allowedPort,
311 Path path, 310 Path path,
312 File file) { 311 File file) {
313 if (allowedPort != -1) { 312 if (allowedPort != -1) {
314 var headerOrigin = request.headers.value('Origin'); 313 var headerOrigin = request.headers.value('Origin');
315 var allowedOrigin; 314 var allowedOrigin;
316 if (headerOrigin != null) { 315 if (headerOrigin != null) {
317 var origin = new Uri(headerOrigin); 316 var origin = Uri.parse(headerOrigin);
318 // Allow loading from http://*:$allowedPort in browsers. 317 // Allow loading from http://*:$allowedPort in browsers.
319 allowedOrigin = 318 allowedOrigin =
320 '${origin.scheme}://${origin.domain}:${allowedPort}'; 319 '${origin.scheme}://${origin.host}:${allowedPort}';
321 } else { 320 } else {
322 // IE10 appears to be bugged and is not sending the Origin header 321 // IE10 appears to be bugged and is not sending the Origin header
323 // when making CORS requests to the same domain but different port. 322 // when making CORS requests to the same domain but different port.
324 allowedOrigin = '*'; 323 allowedOrigin = '*';
325 } 324 }
326 325
327 326
328 response.headers.set("Access-Control-Allow-Origin", allowedOrigin); 327 response.headers.set("Access-Control-Allow-Origin", allowedOrigin);
329 response.headers.set('Access-Control-Allow-Credentials', 'true'); 328 response.headers.set('Access-Control-Allow-Credentials', 'true');
330 } else { 329 } else {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 class _Entry { 380 class _Entry {
382 final String name; 381 final String name;
383 final String displayName; 382 final String displayName;
384 383
385 _Entry(this.name, this.displayName); 384 _Entry(this.name, this.displayName);
386 385
387 int compareTo(_Entry other) { 386 int compareTo(_Entry other) {
388 return name.compareTo(other.name); 387 return name.compareTo(other.name);
389 } 388 }
390 } 389 }
OLDNEW
« no previous file with comments | « tools/testing/dart/browser_controller.dart ('k') | tools/testing/dart/multitest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698