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

Unified Diff: runtime/bin/builtin.dart

Issue 15736023: Remove hack http client and use the one in dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | runtime/bin/dartutils.h » ('j') | runtime/bin/dartutils.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin.dart
diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart
index bae69527f905400553e6dd8622aafff93e491f8c..73736c682f6941b86092847351321e7532f2ce92 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';
+
+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) {
Søren Gjesse 2013/06/03 09:20:00 This is not sufficient to handle the response body
+ _requestCompleted(response, responseData);
+ });
+ }).catchError((error) {
+ _requestFailed(error);
+ });
+}
// Corelib 'print' implementation.
void _print(arg) {
@@ -170,18 +206,3 @@ String _filePathFromHttpUri(Uri uri) {
_logResolution('# Path: $uri');
return uri.toString();
}
-
-String _pathFromHttpUri(String userUri) {
- var uri = Uri.parse(userUri);
- return uri.path;
-}
-
-String _domainFromHttpUri(String userUri) {
- var uri = Uri.parse(userUri);
- return uri.domain;
-}
-
-int _portFromHttpUri(String userUri) {
- var uri = Uri.parse(userUri);
- return uri.port == 0 ? 80 : uri.port;
-}
« no previous file with comments | « no previous file | runtime/bin/dartutils.h » ('j') | runtime/bin/dartutils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698