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 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 | 9 |
10 import 'dart:convert' show | 10 import 'dart:convert' show |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 */ | 119 */ |
120 class TestingServers { | 120 class TestingServers { |
121 static final _CACHE_EXPIRATION_IN_SECONDS = 30; | 121 static final _CACHE_EXPIRATION_IN_SECONDS = 30; |
122 static final _HARMLESS_REQUEST_PATH_ENDINGS = [ | 122 static final _HARMLESS_REQUEST_PATH_ENDINGS = [ |
123 "/apple-touch-icon.png", | 123 "/apple-touch-icon.png", |
124 "/apple-touch-icon-precomposed.png", | 124 "/apple-touch-icon-precomposed.png", |
125 "/favicon.ico", | 125 "/favicon.ico", |
126 "/foo", | 126 "/foo", |
127 "/bar", | 127 "/bar", |
128 "/NonExistingFile", | 128 "/NonExistingFile", |
129 "/NonExistingFile.js", | 129 "IntentionallyMissingFile", |
ricow1
2014/11/04 14:26:59
don't you need a slash in front?
Bill Hesse
2014/11/04 15:23:22
No, the co19 people have been creating new tests u
| |
130 "/hahaURL", | |
131 "/IntentionallyMissingFile", | |
132 "/IntentionallyMissingFile.dart", | |
133 "/IntentionallyMissingFile.html", | |
134 "/IntentionallyMissingFile.png", | |
135 "/IntentionallyMissingFile.css", | |
136 "/IntentionallyMissingFile.jpg", | |
137 "/IntentionallyMissingFile.ttf", | |
138 "/IntentionallyMissingFile.otf", | |
139 "/IntentionallyMissingFile.jpeg" | |
140 ]; | 130 ]; |
141 | 131 |
142 List _serverList = []; | 132 List _serverList = []; |
143 Path _buildDirectory = null; | 133 Path _buildDirectory = null; |
144 Path _dartDirectory = null; | 134 Path _dartDirectory = null; |
145 Path _packageRoot; | 135 Path _packageRoot; |
146 final bool useContentSecurityPolicy; | 136 final bool useContentSecurityPolicy; |
147 final String runtime; | 137 final String runtime; |
148 DispatchingServer _server; | 138 DispatchingServer _server; |
149 | 139 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 } | 402 } |
413 response.headers.removeAll("X-Frame-Options"); | 403 response.headers.removeAll("X-Frame-Options"); |
414 file.openRead().pipe(response).catchError((e) { | 404 file.openRead().pipe(response).catchError((e) { |
415 DebugLogger.warning( | 405 DebugLogger.warning( |
416 'HttpServer: error while closing the response stream', e); | 406 'HttpServer: error while closing the response stream', e); |
417 }); | 407 }); |
418 } | 408 } |
419 | 409 |
420 void _sendNotFound(HttpRequest request) { | 410 void _sendNotFound(HttpRequest request) { |
421 bool isHarmlessPath(String path) { | 411 bool isHarmlessPath(String path) { |
422 return _HARMLESS_REQUEST_PATH_ENDINGS.any((ending) { | 412 return _HARMLESS_REQUEST_PATH_ENDINGS.any((pattern) { |
423 return path.endsWith(ending); | 413 return path.contains(pattern); |
424 }); | 414 }); |
425 } | 415 } |
426 if (!isHarmlessPath(request.uri.path)) { | 416 if (!isHarmlessPath(request.uri.path)) { |
427 DebugLogger.warning('HttpServer: could not find file for request path: ' | 417 DebugLogger.warning('HttpServer: could not find file for request path: ' |
428 '"${request.uri.path}"'); | 418 '"${request.uri.path}"'); |
429 } | 419 } |
430 var response = request.response; | 420 var response = request.response; |
431 response.statusCode = HttpStatus.NOT_FOUND; | 421 response.statusCode = HttpStatus.NOT_FOUND; |
432 | 422 |
433 // Send a nice HTML page detailing the error message. Most browsers expect | 423 // Send a nice HTML page detailing the error message. Most browsers expect |
(...skipping 27 matching lines...) Expand all Loading... | |
461 class _Entry implements Comparable { | 451 class _Entry implements Comparable { |
462 final String name; | 452 final String name; |
463 final String displayName; | 453 final String displayName; |
464 | 454 |
465 _Entry(this.name, this.displayName); | 455 _Entry(this.name, this.displayName); |
466 | 456 |
467 int compareTo(_Entry other) { | 457 int compareTo(_Entry other) { |
468 return name.compareTo(other.name); | 458 return name.compareTo(other.name); |
469 } | 459 } |
470 } | 460 } |
OLD | NEW |