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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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) 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 part of vmservice_io; 5 part of vmservice_io;
6 6
7 class WebSocketClient extends Client { 7 class WebSocketClient extends Client {
8 static const int PARSE_ERROR_CODE = 4000; 8 static const int PARSE_ERROR_CODE = 4000;
9 static const int BINARY_MESSAGE_ERROR_CODE = 4001; 9 static const int BINARY_MESSAGE_ERROR_CODE = 4001;
10 static const int NOT_MAP_ERROR_CODE = 4002; 10 static const int NOT_MAP_ERROR_CODE = 4002;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 close(); 89 close();
90 } 90 }
91 91
92 void post(dynamic result) { 92 void post(dynamic result) {
93 if (result == null) { 93 if (result == null) {
94 close(); 94 close();
95 return; 95 return;
96 } 96 }
97 HttpResponse response = request.response; 97 HttpResponse response = request.response;
98 response.headers.contentType = jsonContentType; 98 response.headers.contentType = jsonContentType;
99 final uri = Uri.parse(request.headers['Origin'].single ?? ''); 99 final origins = request.headers['Origin'];
100 final noPortOrigin = new Uri(host: uri.host, scheme: uri.scheme).origin; 100 if ((origins != null) && (origins.isNotEmpty)) {
101 if (_allowedOrigins.contains(noPortOrigin)) { 101 final uri = Uri.parse(origins.first);
102 response.headers.add('Access-Control-Allow-Origin', uri.origin); 102 final noPortOrigin = new Uri(host: uri.host, scheme: uri.scheme).origin;
103 if (_allowedOrigins.contains(noPortOrigin)) {
104 response.headers.add('Access-Control-Allow-Origin', uri.origin);
105 }
103 } 106 }
104 if (result is String) { 107 if (result is String) {
105 response.write(result); 108 response.write(result);
106 } else { 109 } else {
107 assert(result is List); 110 assert(result is List);
108 Uint8List cstring = result[0]; // Already in UTF-8. 111 Uint8List cstring = result[0]; // Already in UTF-8.
109 response.add(cstring); 112 response.add(cstring);
110 } 113 }
111 response.close(); 114 response.close();
112 close(); 115 close();
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 _notifyServerState("", 0); 329 _notifyServerState("", 0);
327 onServerAddressChange(null); 330 onServerAddressChange(null);
328 return this; 331 return this;
329 }); 332 });
330 } 333 }
331 334
332 } 335 }
333 336
334 void _notifyServerState(String ip, int port) 337 void _notifyServerState(String ip, int port)
335 native "VMServiceIO_NotifyServerState"; 338 native "VMServiceIO_NotifyServerState";
OLDNEW
« 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