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

Side by Side Diff: utils/pub/http.dart

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 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 | « utils/apidoc/apidoc.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »
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 /// Helpers for dealing with HTTP. 5 /// Helpers for dealing with HTTP.
6 library pub.http; 6 library pub.http;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:json' as json; 10 import 'dart:json' as json;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 return http.Response.fromStream(streamedResponse).then((response) { 54 return http.Response.fromStream(streamedResponse).then((response) {
55 throw new PubHttpException(response); 55 throw new PubHttpException(response);
56 }); 56 });
57 }).catchError((asyncError) { 57 }).catchError((asyncError) {
58 if (asyncError.error is SocketIOException && 58 if (asyncError.error is SocketIOException &&
59 asyncError.error.osError != null) { 59 asyncError.error.osError != null) {
60 if (asyncError.error.osError.errorCode == 8 || 60 if (asyncError.error.osError.errorCode == 8 ||
61 asyncError.error.osError.errorCode == -2 || 61 asyncError.error.osError.errorCode == -2 ||
62 asyncError.error.osError.errorCode == -5 || 62 asyncError.error.osError.errorCode == -5 ||
63 asyncError.error.osError.errorCode == 11001 ||
63 asyncError.error.osError.errorCode == 11004) { 64 asyncError.error.osError.errorCode == 11004) {
64 throw 'Could not resolve URL "${request.url.origin}".'; 65 throw 'Could not resolve URL "${request.url.origin}".';
65 } else if (asyncError.error.osError.errorCode == -12276) { 66 } else if (asyncError.error.osError.errorCode == -12276) {
66 throw 'Unable to validate SSL certificate for ' 67 throw 'Unable to validate SSL certificate for '
67 '"${request.url.origin}".'; 68 '"${request.url.origin}".';
68 } 69 }
69 } 70 }
70 throw asyncError; 71 throw asyncError;
71 }), HTTP_TIMEOUT, 'fetching URL "${request.url}"'); 72 }), HTTP_TIMEOUT, 'fetching URL "${request.url}"');
72 } 73 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 127
127 /// Exception thrown when an HTTP operation fails. 128 /// Exception thrown when an HTTP operation fails.
128 class PubHttpException implements Exception { 129 class PubHttpException implements Exception {
129 final http.Response response; 130 final http.Response response;
130 131
131 const PubHttpException(this.response); 132 const PubHttpException(this.response);
132 133
133 String toString() => 'HTTP error ${response.statusCode}: ' 134 String toString() => 'HTTP error ${response.statusCode}: '
134 '${response.reasonPhrase}'; 135 '${response.reasonPhrase}';
135 } 136 }
OLDNEW
« no previous file with comments | « utils/apidoc/apidoc.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698