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

Side by Side Diff: runtime/bin/vmservice/server.dart

Issue 2733413003: Support DevFS paths encoded as URIs (Closed)
Patch Set: Created 3 years, 9 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
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 final bool silentObservatory = 7 final bool silentObservatory =
8 const bool.fromEnvironment('SILENT_OBSERVATORY'); 8 const bool.fromEnvironment('SILENT_OBSERVATORY');
9 9
10 void serverPrint(String s) { 10 void serverPrint(String s) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // This is a cross origin attempt to connect 226 // This is a cross origin attempt to connect
227 request.response.close(); 227 request.response.close();
228 return; 228 return;
229 } 229 }
230 if (request.method == 'PUT') { 230 if (request.method == 'PUT') {
231 // PUT requests are forwarded to DevFS for processing. 231 // PUT requests are forwarded to DevFS for processing.
232 232
233 List fsNameList; 233 List fsNameList;
234 List fsPathList; 234 List fsPathList;
235 List fsPathBase64List; 235 List fsPathBase64List;
236 List fsUriBase64List;
236 Object fsName; 237 Object fsName;
237 Object fsPath; 238 Object fsPath;
239 Object fsUri;
238 240
239 try { 241 try {
240 // Extract the fs name and fs path from the request headers. 242 // Extract the fs name and fs path from the request headers.
241 fsNameList = request.headers['dev_fs_name']; 243 fsNameList = request.headers['dev_fs_name'];
242 fsName = fsNameList[0]; 244 fsName = fsNameList[0];
243 245
244 fsPathList = request.headers['dev_fs_path']; 246 // Prefer Uri encoding first.
245 fsPathBase64List = request.headers['dev_fs_path_b64']; 247 fsUriBase64List = request.headers['dev_fs_uri_b64'];
246 // If the 'dev_fs_path_b64' header field was sent, use that instead. 248 if ((fsUriBase64List != null) && (fsUriBase64List.length > 0)) {
247 if ((fsPathBase64List != null) && (fsPathBase64List.length > 0)) { 249 String decodedFsUri = UTF8.decode(BASE64.decode(fsUriBase64List[0]));
248 fsPath = UTF8.decode(BASE64.decode(fsPathBase64List[0])); 250 fsUri = Uri.parse(decodedFsUri);
249 } else { 251 }
250 fsPath = fsPathList[0]; 252
253 // Fallback to path encoding.
254 if (fsUri == null) {
255 fsPathList = request.headers['dev_fs_path'];
256 fsPathBase64List = request.headers['dev_fs_path_b64'];
257 // If the 'dev_fs_path_b64' header field was sent, use that instead.
258 if ((fsPathBase64List != null) && (fsPathBase64List.length > 0)) {
259 fsPath = UTF8.decode(BASE64.decode(fsPathBase64List[0]));
260 } else {
261 fsPath = fsPathList[0];
262 }
251 } 263 }
252 } catch (e) { /* ignore */ } 264 } catch (e) { /* ignore */ }
253 265
254 String result; 266 String result;
255 try { 267 try {
256 result = await _service.devfs.handlePutStream( 268 result = await _service.devfs.handlePutStream(
257 fsName, 269 fsName,
258 fsPath, 270 fsPath,
271 fsUri,
259 request.transform(GZIP.decoder)); 272 request.transform(GZIP.decoder));
260 } catch (e) { /* ignore */ } 273 } catch (e) { /* ignore */ }
261 274
262 if (result != null) { 275 if (result != null) {
263 request.response.headers.contentType = 276 request.response.headers.contentType =
264 HttpRequestClient.jsonContentType; 277 HttpRequestClient.jsonContentType;
265 request.response.write(result); 278 request.response.write(result);
266 } 279 }
267 request.response.close(); 280 request.response.close();
268 return; 281 return;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 _notifyServerState(""); 383 _notifyServerState("");
371 onServerAddressChange(null); 384 onServerAddressChange(null);
372 return this; 385 return this;
373 }); 386 });
374 } 387 }
375 388
376 } 389 }
377 390
378 void _notifyServerState(String uri) 391 void _notifyServerState(String uri)
379 native "VMServiceIO_NotifyServerState"; 392 native "VMServiceIO_NotifyServerState";
OLDNEW
« no previous file with comments | « no previous file | runtime/observatory/tests/service/dev_fs_uri_test.dart » ('j') | sdk/lib/vmservice/devfs.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698