| 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 library curl_client; | 5 library curl_client; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import '../../pkg/http/lib/http.dart' as http; | 10 import '../../pkg/http/lib/http.dart' as http; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } else { | 129 } else { |
| 130 throw new HttpException(message); | 130 throw new HttpException(message); |
| 131 } | 131 } |
| 132 }), completer); | 132 }), completer); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 // If there's not going to be a response body (e.g. for HEAD requests), curl | 135 // If there's not going to be a response body (e.g. for HEAD requests), curl |
| 136 // prints the headers to stdout instead of the body. We want to wait until | 136 // prints the headers to stdout instead of the body. We want to wait until |
| 137 // all the headers are received to read them from the header file. | 137 // all the headers are received to read them from the header file. |
| 138 if (!expectBody) { | 138 if (!expectBody) { |
| 139 return Futures.wait([ | 139 return Future.wait([ |
| 140 consumeInputStream(process.stdout), | 140 consumeInputStream(process.stdout), |
| 141 completer.future | 141 completer.future |
| 142 ]); | 142 ]); |
| 143 } | 143 } |
| 144 | 144 |
| 145 return completer.future; | 145 return completer.future; |
| 146 } | 146 } |
| 147 | 147 |
| 148 /// Returns a [http.StreamedResponse] from the response data printed by the | 148 /// Returns a [http.StreamedResponse] from the response data printed by the |
| 149 /// `curl` [process]. [lines] are the headers that `curl` wrote to a file. | 149 /// `curl` [process]. [lines] are the headers that `curl` wrote to a file. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 /// path to the bundled `curl.exe`; elsewhere, this is just "curl", and we | 189 /// path to the bundled `curl.exe`; elsewhere, this is just "curl", and we |
| 190 /// assume it to be installed and on the user's PATH. | 190 /// assume it to be installed and on the user's PATH. |
| 191 static String get _defaultExecutable { | 191 static String get _defaultExecutable { |
| 192 if (Platform.operatingSystem != 'windows') return 'curl'; | 192 if (Platform.operatingSystem != 'windows') return 'curl'; |
| 193 // Note: This line of code gets munged by create_sdk.py to be the correct | 193 // Note: This line of code gets munged by create_sdk.py to be the correct |
| 194 // relative path to curl in the SDK. | 194 // relative path to curl in the SDK. |
| 195 var pathToCurl = "../../third_party/curl/curl.exe"; | 195 var pathToCurl = "../../third_party/curl/curl.exe"; |
| 196 return relativeToPub(pathToCurl); | 196 return relativeToPub(pathToCurl); |
| 197 } | 197 } |
| 198 } | 198 } |
| OLD | NEW |