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

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.cc » ('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..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) {
« no previous file with comments | « no previous file | runtime/bin/dartutils.cc » ('j') | runtime/bin/dartutils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698