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

Side by Side Diff: runtime/bin/builtin.dart

Issue 18438005: Move MimeMultipartTransformer and HttpBodyHandler to mime and http_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed _BufferList copy and MimeMultipartException reference in pub. Created 7 years, 5 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
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'; 6 import 'dart:io';
7 import 'dart:typed_data';
7 8
8 // Corelib 'print' implementation. 9 // Corelib 'print' implementation.
9 void _print(arg) { 10 void _print(arg) {
10 _Logger._printString(arg.toString()); 11 _Logger._printString(arg.toString());
11 } 12 }
12 13
13 14
14 class _Logger { 15 class _Logger {
15 static void _printString(String s) native "Logger_PrintString"; 16 static void _printString(String s) native "Logger_PrintString";
16 } 17 }
(...skipping 11 matching lines...) Expand all
28 29
29 30
30 var _httpRequestResponseCode = 0; 31 var _httpRequestResponseCode = 0;
31 var _httpRequestStatusString; 32 var _httpRequestStatusString;
32 var _httpRequestResponse; 33 var _httpRequestResponse;
33 34
34 _getHttpRequestResponseCode() => _httpRequestResponseCode; 35 _getHttpRequestResponseCode() => _httpRequestResponseCode;
35 _getHttpRequestStatusString() => _httpRequestStatusString; 36 _getHttpRequestStatusString() => _httpRequestStatusString;
36 _getHttpRequestResponse() => _httpRequestResponse; 37 _getHttpRequestResponse() => _httpRequestResponse;
37 38
38 void _requestCompleted(HttpClientResponseBody body) { 39 void _requestCompleted(List<int> data, HttpClientResponse response) {
39 _httpRequestResponseCode = body.statusCode; 40 _httpRequestResponseCode = response.statusCode;
40 _httpRequestStatusString = '${body.statusCode} ${body.reasonPhrase}'; 41 _httpRequestStatusString = '${response.statusCode} ${response.reasonPhrase}';
41 _httpRequestResponse = null; 42 _httpRequestResponse = null;
42 if (body.statusCode != 200 || body.type == 'json') { 43 if (response.statusCode != 200 ||
44 (response.headers.contentType != null &&
45 response.headers.contentType.mimeType == 'application/json')) {
43 return; 46 return;
44 } 47 }
45 _httpRequestResponse = body.body; 48 _httpRequestResponse = data;
46 } 49 }
47 50
48 51
49 void _requestFailed(error) { 52 void _requestFailed(error) {
50 _httpRequestResponseCode = 0; 53 _httpRequestResponseCode = 0;
51 _httpRequestStatusString = error.toString(); 54 _httpRequestStatusString = error.toString();
52 _httpRequestResponse = null; 55 _httpRequestResponse = null;
53 } 56 }
54 57
55 58
56 void _makeHttpRequest(String uri) { 59 void _makeHttpRequest(String uri) {
57 var _client = new HttpClient(); 60 var _client = new HttpClient();
58 _httpRequestResponseCode = 0; 61 _httpRequestResponseCode = 0;
59 _httpRequestStatusString = null; 62 _httpRequestStatusString = null;
60 _httpRequestResponse = null; 63 _httpRequestResponse = null;
61 Uri requestUri = Uri.parse(uri); 64 Uri requestUri = Uri.parse(uri);
62 _client.getUrl(requestUri) 65 _client.getUrl(requestUri)
63 .then((HttpClientRequest request) => request.close()) 66 .then((HttpClientRequest request) => request.close())
64 .then(HttpBodyHandler.processResponse) 67 .then((HttpClientResponse response) {
65 .then((HttpClientResponseBody body) { 68 return response
66 _requestCompleted(body); 69 .fold(new BytesBuilder(), (b, d) => b..add(d))
70 .then((builder) {
71 _requestCompleted(builder.takeBytes(), response);
72 });
67 }).catchError((error) { 73 }).catchError((error) {
68 _requestFailed(error); 74 _requestFailed(error);
69 }); 75 });
70 } 76 }
71 77
72 78
73 // Are we running on Windows? 79 // Are we running on Windows?
74 var _isWindows = false; 80 var _isWindows = false;
75 // The current working directory 81 // The current working directory
76 var _workingDirectoryUri; 82 var _workingDirectoryUri;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 270 }
265 _logResolution('# Package: $uri -> $path'); 271 _logResolution('# Package: $uri -> $path');
266 return path; 272 return path;
267 } 273 }
268 274
269 275
270 String _filePathFromHttpUri(Uri uri) { 276 String _filePathFromHttpUri(Uri uri) {
271 _logResolution('# Path: $uri -> $uri'); 277 _logResolution('# Path: $uri -> $uri');
272 return uri.toString(); 278 return uri.toString();
273 } 279 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698