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); |
}); |