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

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

Issue 2225583002: Support devFS writes via HTTP PUT (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rmacnak review Created 4 years, 4 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 | runtime/bin/vmservice/vmservice_io.dart » ('j') | 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 4e4c54ae2b9e4714f41b31964376179bd3147501..4075e8d427886d363b4b9c31aabeba5ad5c1c7be 100644
--- a/runtime/bin/vmservice/server.dart
+++ b/runtime/bin/vmservice/server.dart
@@ -157,12 +157,44 @@ class Server {
return false;
}
- void _requestHandler(HttpRequest request) {
+ Future _requestHandler(HttpRequest request) async {
if (!_originCheck(request)) {
// This is a cross origin attempt to connect
request.response.close();
return;
}
+ if (request.method == 'PUT') {
+ // PUT requests are forwarded to DevFS for processing.
+
+ List fsNameList;
+ List fsPathList;
+ Object fsName;
+ Object fsPath;
+
+ try {
+ // Extract the fs name and fs path from the request headers.
+ fsNameList = request.headers['dev_fs_name'];
+ fsPathList = request.headers['dev_fs_path'];
+ fsName = fsNameList[0];
+ fsPath = fsPathList[0];
+ } catch (e) { /* ignore */ }
+
+ String result;
+ try {
+ result = await _service.devfs.handlePutStream(
+ fsName,
+ fsPath,
+ request.transform(GZIP.decoder));
+ } catch (e) { /* ignore */ }
+
+ if (result != null) {
+ request.response.headers.contentType =
+ HttpRequestClient.jsonContentType;
+ request.response.write(result);
+ }
+ request.response.close();
+ return;
+ }
if (request.method != 'GET') {
// Not a GET request. Do nothing.
request.response.close();
« no previous file with comments | « no previous file | runtime/bin/vmservice/vmservice_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698