| OLD | NEW |
| 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:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 error.osError.errorCode == -2 || | 92 error.osError.errorCode == -2 || |
| 93 error.osError.errorCode == -5 || | 93 error.osError.errorCode == -5 || |
| 94 error.osError.errorCode == 11001 || | 94 error.osError.errorCode == 11001 || |
| 95 error.osError.errorCode == 11004) { | 95 error.osError.errorCode == 11004) { |
| 96 fail('Could not resolve URL "${request.url.origin}".'); | 96 fail('Could not resolve URL "${request.url.origin}".'); |
| 97 } else if (error.osError.errorCode == -12276) { | 97 } else if (error.osError.errorCode == -12276) { |
| 98 fail('Unable to validate SSL certificate for ' | 98 fail('Unable to validate SSL certificate for ' |
| 99 '"${request.url.origin}".'); | 99 '"${request.url.origin}".'); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 print('Error in PubHttpClient.send (issue 12581) error: $error'); |
| 103 print(' stacktrace: $stackTrace'); |
| 102 throw error; | 104 throw error; |
| 103 }), HTTP_TIMEOUT, 'fetching URL "${request.url}"'); | 105 }), HTTP_TIMEOUT, 'fetching URL "${request.url}"'); |
| 104 } | 106 } |
| 105 | 107 |
| 106 /// Logs the fact that [request] was sent, and information about it. | 108 /// Logs the fact that [request] was sent, and information about it. |
| 107 void _logRequest(http.BaseRequest request) { | 109 void _logRequest(http.BaseRequest request) { |
| 108 var requestLog = new StringBuffer(); | 110 var requestLog = new StringBuffer(); |
| 109 requestLog.writeln("HTTP ${request.method} ${request.url}"); | 111 requestLog.writeln("HTTP ${request.method} ${request.url}"); |
| 110 request.headers.forEach((name, value) => | 112 request.headers.forEach((name, value) => |
| 111 requestLog.writeln(_logField(name, value))); | 113 requestLog.writeln(_logField(name, value))); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 219 |
| 218 /// Exception thrown when an HTTP operation fails. | 220 /// Exception thrown when an HTTP operation fails. |
| 219 class PubHttpException implements Exception { | 221 class PubHttpException implements Exception { |
| 220 final http.Response response; | 222 final http.Response response; |
| 221 | 223 |
| 222 const PubHttpException(this.response); | 224 const PubHttpException(this.response); |
| 223 | 225 |
| 224 String toString() => 'HTTP error ${response.statusCode}: ' | 226 String toString() => 'HTTP error ${response.statusCode}: ' |
| 225 '${response.reasonPhrase}'; | 227 '${response.reasonPhrase}'; |
| 226 } | 228 } |
| OLD | NEW |