mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 20:51:19 +00:00
Upload requests handler added to test servers
Change-Id: I86d65a11afadb367ef28d91e1daeca23adeb9a19 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221946 Reviewed-by: Alexander Thomas <athom@google.com> Commit-Queue: Alexander Thomas <athom@google.com>
This commit is contained in:
parent
e78f715541
commit
b0977940fa
|
@ -166,6 +166,7 @@ class TestingServers {
|
|||
server.addHandler('/$prefixBuildDir', fileHandler);
|
||||
server.addHandler('/$prefixDartDir', fileHandler);
|
||||
server.addHandler('/packages', fileHandler);
|
||||
server.addHandler('/upload', _handleUploadRequest);
|
||||
_serverList.add(httpServer);
|
||||
return server;
|
||||
});
|
||||
|
@ -237,6 +238,23 @@ class TestingServers {
|
|||
});
|
||||
}
|
||||
|
||||
void _handleUploadRequest(HttpRequest request) async {
|
||||
try {
|
||||
var builder = await request.fold(BytesBuilder(), (var b, var d) {
|
||||
b.add(d);
|
||||
return b;
|
||||
});
|
||||
var data = builder.takeBytes();
|
||||
DebugLogger.info(
|
||||
'Uploaded data: ${String.fromCharCodes(data as Iterable<int>)}');
|
||||
request.response.headers.set("Access-Control-Allow-Origin", "*");
|
||||
request.response.close();
|
||||
} catch (e) {
|
||||
DebugLogger.warning(
|
||||
'HttpServer: error while processing upload request', e);
|
||||
}
|
||||
}
|
||||
|
||||
Uri _getFileUriFromRequestUri(Uri request) {
|
||||
// Go to the top of the file to see an explanation of the URL path scheme.
|
||||
var pathSegments = request.normalizePath().pathSegments;
|
||||
|
|
Loading…
Reference in a new issue