Chromium Code Reviews| Index: runtime/bin/builtin.dart |
| diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart |
| index bae69527f905400553e6dd8622aafff93e491f8c..16bf391d3b0af2553143bec3c8f32e1ee8f0d5de 100644 |
| --- a/runtime/bin/builtin.dart |
| +++ b/runtime/bin/builtin.dart |
| @@ -3,6 +3,42 @@ |
| // BSD-style license that can be found in the LICENSE file. |
| library builtin; |
| +import 'dart:io'; |
|
siva
2013/05/31 21:02:02
I hope we won't get into any bootstrapping issues
|
| + |
| +int _httpRequestResponseCode = 0; |
| +String _httpRequestStatusString; |
| +List<int> _httpRequestResponse; |
| + |
| +void _requestCompleted(HttpClientResponse response, List<int> responseData) { |
| + _httpRequestResponseCode = response.statusCode; |
| + _httpRequestStatusString = '${response.statusCode} ${response.reasonPhrase}'; |
| + _httpRequestResponse = responseData; |
| +} |
| + |
| +void _requestFailed(error) { |
| + _httpRequestResponseCode = 0; |
| + _httpRequestStatusString = error.toString(); |
| + _httpRequestResponse = null; |
| +} |
| + |
| +HttpClient _client = new HttpClient(); |
| +void _makeHttpRequest(String uri) { |
| + _httpRequestResponseCode = 0; |
| + _httpRequestStatusString = null; |
| + _httpRequestResponse = null; |
| + |
| + Uri requestUri = Uri.parse(uri); |
| + |
| + _client.getUrl(requestUri).then((HttpClientRequest request) { |
| + return request.close(); |
| + }).then((HttpClientResponse response) { |
| + response.listen((List<int> responseData) { |
| + _requestCompleted(response, responseData); |
| + }); |
| + }).catchError((error) { |
| + _requestFailed(error); |
| + }); |
| +} |
| // Corelib 'print' implementation. |
| void _print(arg) { |
| @@ -178,7 +214,7 @@ String _pathFromHttpUri(String userUri) { |
| String _domainFromHttpUri(String userUri) { |
| var uri = Uri.parse(userUri); |
| - return uri.domain; |
| + return uri.host; |
| } |
| int _portFromHttpUri(String userUri) { |