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

Unified Diff: runtime/bin/vmservice/server.dart

Issue 2308083002: Added service protocol cross-origin access from localhost for http requests (Closed)
Patch Set: Added missing code Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/server.dart
diff --git a/runtime/bin/vmservice/server.dart b/runtime/bin/vmservice/server.dart
index f6dc7b85406c545f64878125109eceea4828641b..8d6a932ffc515acb8995632adad54ba59434f970 100644
--- a/runtime/bin/vmservice/server.dart
+++ b/runtime/bin/vmservice/server.dart
@@ -96,10 +96,13 @@ class HttpRequestClient extends Client {
}
HttpResponse response = request.response;
response.headers.contentType = jsonContentType;
- final uri = Uri.parse(request.headers['Origin'].single ?? '');
- final noPortOrigin = new Uri(host: uri.host, scheme: uri.scheme).origin;
- if (_allowedOrigins.contains(noPortOrigin)) {
- response.headers.add('Access-Control-Allow-Origin', uri.origin);
+ final origins = request.headers['Origin'];
+ if ((origins != null) && (origins.isNotEmpty)) {
+ final uri = Uri.parse(origins.first);
+ final noPortOrigin = new Uri(host: uri.host, scheme: uri.scheme).origin;
+ if (_allowedOrigins.contains(noPortOrigin)) {
+ response.headers.add('Access-Control-Allow-Origin', uri.origin);
+ }
}
if (result is String) {
response.write(result);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698