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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/dartutils.h » ('j') | runtime/bin/dartutils.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library builtin; 5 library builtin;
6 import 'dart:io';
7
8 int _httpRequestResponseCode = 0;
9 String _httpRequestStatusString;
10 List<int> _httpRequestResponse;
11
12 void _requestCompleted(HttpClientResponse response, List<int> responseData) {
13 _httpRequestResponseCode = response.statusCode;
14 _httpRequestStatusString = '${response.statusCode} ${response.reasonPhrase}';
15 _httpRequestResponse = responseData;
16 }
17
18 void _requestFailed(error) {
19 _httpRequestResponseCode = 0;
20 _httpRequestStatusString = error.toString();
21 _httpRequestResponse = null;
22 }
23
24 HttpClient _client = new HttpClient();
25 void _makeHttpRequest(String uri) {
26 _httpRequestResponseCode = 0;
27 _httpRequestStatusString = null;
28 _httpRequestResponse = null;
29
30 Uri requestUri = Uri.parse(uri);
31
32 _client.getUrl(requestUri).then((HttpClientRequest request) {
33 return request.close();
34 }).then((HttpClientResponse response) {
35 response.listen((List<int> responseData) {
Søren Gjesse 2013/06/03 09:20:00 This is not sufficient to handle the response body
36 _requestCompleted(response, responseData);
37 });
38 }).catchError((error) {
39 _requestFailed(error);
40 });
41 }
6 42
7 // Corelib 'print' implementation. 43 // Corelib 'print' implementation.
8 void _print(arg) { 44 void _print(arg) {
9 _Logger._printString(arg.toString()); 45 _Logger._printString(arg.toString());
10 } 46 }
11 47
12 class _Logger { 48 class _Logger {
13 static void _printString(String s) native "Logger_PrintString"; 49 static void _printString(String s) native "Logger_PrintString";
14 } 50 }
15 51
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 199 }
164 200
165 _logResolution("# Package: $path"); 201 _logResolution("# Package: $path");
166 return path; 202 return path;
167 } 203 }
168 204
169 String _filePathFromHttpUri(Uri uri) { 205 String _filePathFromHttpUri(Uri uri) {
170 _logResolution('# Path: $uri'); 206 _logResolution('# Path: $uri');
171 return uri.toString(); 207 return uri.toString();
172 } 208 }
173
174 String _pathFromHttpUri(String userUri) {
175 var uri = Uri.parse(userUri);
176 return uri.path;
177 }
178
179 String _domainFromHttpUri(String userUri) {
180 var uri = Uri.parse(userUri);
181 return uri.domain;
182 }
183
184 int _portFromHttpUri(String userUri) {
185 var uri = Uri.parse(userUri);
186 return uri.port == 0 ? 80 : uri.port;
187 }
OLDNEW
« 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