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

Side by Side 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: .. 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/bin/vmservice/vmservice_io.dart » ('j') | 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return true; 150 return true;
151 } 151 }
152 for (String origin in origins) { 152 for (String origin in origins) {
153 if (_isAllowedOrigin(origin)) { 153 if (_isAllowedOrigin(origin)) {
154 return true; 154 return true;
155 } 155 }
156 } 156 }
157 return false; 157 return false;
158 } 158 }
159 159
160 void _requestHandler(HttpRequest request) { 160 Future _requestHandler(HttpRequest request) async {
161 if (!_originCheck(request)) { 161 if (!_originCheck(request)) {
162 // This is a cross origin attempt to connect 162 // This is a cross origin attempt to connect
163 request.response.close(); 163 request.response.close();
164 return; 164 return;
165 } 165 }
166 if (request.method == 'PUT') {
167 // PUT requests are forwarded to DevFS for processing.
168
169 Object fsNameList;
rmacnak 2016/08/08 16:33:42 var or List: fsNameList[0] below is a static warni
Cutch 2016/08/08 17:22:05 Done.
170 Object fsPathList;
171 Object fsName;
172 Object fsPath;
173
174 try {
175 // Extract the fs name and fs path from the request headers.
176 fsNameList = request.headers['dev_fs_name'];
177 fsPathList = request.headers['dev_fs_path'];
178 fsName = fsNameList[0];
179 fsPath = fsPathList[0];
180 } catch (e) { /* ignore */ }
181
182 String result;
183 try {
184 result = await _service.devfs.handlePutStream(
185 fsName,
186 fsPath,
187 request.transform(GZIP.decoder));
188 } catch (e) { /* ignore */ }
rmacnak 2016/08/08 16:33:42 A write error (out of disk space) would end up her
Cutch 2016/08/08 17:22:05 DevFS currently doesn't report write errors or out
189
190 if (result != null) {
191 request.response.headers.contentType =
192 HttpRequestClient.jsonContentType;
193 request.response.write(result);
194 }
195 request.response.close();
196 return;
197 }
166 if (request.method != 'GET') { 198 if (request.method != 'GET') {
167 // Not a GET request. Do nothing. 199 // Not a GET request. Do nothing.
168 request.response.close(); 200 request.response.close();
169 return; 201 return;
170 } 202 }
171 203
172 final String path = 204 final String path =
173 request.uri.path == '/' ? ROOT_REDIRECT_PATH : request.uri.path; 205 request.uri.path == '/' ? ROOT_REDIRECT_PATH : request.uri.path;
174 206
175 if (path == WEBSOCKET_PATH) { 207 if (path == WEBSOCKET_PATH) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 _notifyServerState("", 0); 304 _notifyServerState("", 0);
273 onServerAddressChange(null); 305 onServerAddressChange(null);
274 return this; 306 return this;
275 }); 307 });
276 } 308 }
277 309
278 } 310 }
279 311
280 void _notifyServerState(String ip, int port) 312 void _notifyServerState(String ip, int port)
281 native "VMServiceIO_NotifyServerState"; 313 native "VMServiceIO_NotifyServerState";
OLDNEW
« 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