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

Unified Diff: runtime/bin/builtin.dart

Issue 18438005: Move MimeMultipartTransformer and HttpBodyHandler to mime and http_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed _BufferList copy and MimeMultipartException reference in pub. Created 7 years, 5 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
Index: runtime/bin/builtin.dart
diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart
index 818acaf7c7ab5ee7b7e3cce51573baac6c2008c5..b14b1cc49519636b2767866374fa8e95381fa769 100644
--- a/runtime/bin/builtin.dart
+++ b/runtime/bin/builtin.dart
@@ -4,6 +4,7 @@
library builtin;
import 'dart:io';
+import 'dart:typed_data';
// Corelib 'print' implementation.
void _print(arg) {
@@ -35,14 +36,16 @@ _getHttpRequestResponseCode() => _httpRequestResponseCode;
_getHttpRequestStatusString() => _httpRequestStatusString;
_getHttpRequestResponse() => _httpRequestResponse;
-void _requestCompleted(HttpClientResponseBody body) {
- _httpRequestResponseCode = body.statusCode;
- _httpRequestStatusString = '${body.statusCode} ${body.reasonPhrase}';
+void _requestCompleted(List<int> data, HttpClientResponse response) {
+ _httpRequestResponseCode = response.statusCode;
+ _httpRequestStatusString = '${response.statusCode} ${response.reasonPhrase}';
_httpRequestResponse = null;
- if (body.statusCode != 200 || body.type == 'json') {
+ if (response.statusCode != 200 ||
+ (response.headers.contentType != null &&
+ response.headers.contentType.mimeType == 'application/json')) {
return;
}
- _httpRequestResponse = body.body;
+ _httpRequestResponse = data;
}
@@ -61,9 +64,12 @@ void _makeHttpRequest(String uri) {
Uri requestUri = Uri.parse(uri);
_client.getUrl(requestUri)
.then((HttpClientRequest request) => request.close())
- .then(HttpBodyHandler.processResponse)
- .then((HttpClientResponseBody body) {
- _requestCompleted(body);
+ .then((HttpClientResponse response) {
+ return response
+ .fold(new BytesBuilder(), (b, d) => b..add(d))
+ .then((builder) {
+ _requestCompleted(builder.takeBytes(), response);
+ });
}).catchError((error) {
_requestFailed(error);
});

Powered by Google App Engine
This is Rietveld 408576698