Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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'; | 10 import 'dart:uri'; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 response.outputStream.writeString(footer); | 261 response.outputStream.writeString(footer); |
| 262 response.outputStream.close(); | 262 response.outputStream.close(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 void _sendFileContent(HttpRequest request, | 265 void _sendFileContent(HttpRequest request, |
| 266 HttpResponse response, | 266 HttpResponse response, |
| 267 int allowedPort, | 267 int allowedPort, |
| 268 Path path, | 268 Path path, |
| 269 File file) { | 269 File file) { |
| 270 if (allowedPort != -1) { | 270 if (allowedPort != -1) { |
| 271 var origin = new Uri(request.headers.value('Origin')); | 271 var headerOrigin = request.headers.value('Origin'); |
| 272 // Allow loading from http://*:$allowedPort in browsers. | 272 var allowedOrigin; |
| 273 var allowedOrigin = | 273 if (headerOrigin != null) { |
| 274 var origin = new Uri(headerOrigin); | |
| 275 // Allow loading from http://*:$allowedPort in browsers. | |
| 276 allowedOrigin = | |
| 274 '${origin.scheme}://${origin.domain}:${allowedPort}'; | 277 '${origin.scheme}://${origin.domain}:${allowedPort}'; |
| 278 } else { | |
| 279 // IE10 appears to be bugged and is not sending the Origin header | |
| 280 // when making CORS requests to the same domain but different port. | |
| 281 allowedOrigin = '*'; | |
|
kustermann
2013/03/16 22:41:19
I think this is not the right approach:
You know
| |
| 282 } | |
| 283 | |
| 284 | |
| 275 response.headers.set("Access-Control-Allow-Origin", allowedOrigin); | 285 response.headers.set("Access-Control-Allow-Origin", allowedOrigin); |
| 276 response.headers.set('Access-Control-Allow-Credentials', 'true'); | 286 response.headers.set('Access-Control-Allow-Credentials', 'true'); |
| 277 } else { | 287 } else { |
| 278 // No allowedPort specified. Allow from anywhere (but cross-origin | 288 // No allowedPort specified. Allow from anywhere (but cross-origin |
| 279 // requests *with credentials* will fail because you can't use "*"). | 289 // requests *with credentials* will fail because you can't use "*"). |
| 280 response.headers.set("Access-Control-Allow-Origin", "*"); | 290 response.headers.set("Access-Control-Allow-Origin", "*"); |
| 281 } | 291 } |
| 282 if (useContentSecurityPolicy) { | 292 if (useContentSecurityPolicy) { |
| 283 // Chrome respects the standardized Content-Security-Policy header, | 293 // Chrome respects the standardized Content-Security-Policy header, |
| 284 // whereas Firefox and IE10 use X-Content-Security-Policy. Safari | 294 // whereas Firefox and IE10 use X-Content-Security-Policy. Safari |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 class _Entry { | 333 class _Entry { |
| 324 final String name; | 334 final String name; |
| 325 final String displayName; | 335 final String displayName; |
| 326 | 336 |
| 327 _Entry(this.name, this.displayName); | 337 _Entry(this.name, this.displayName); |
| 328 | 338 |
| 329 int compareTo(_Entry other) { | 339 int compareTo(_Entry other) { |
| 330 return name.compareTo(other.name); | 340 return name.compareTo(other.name); |
| 331 } | 341 } |
| 332 } | 342 } |
| OLD | NEW |