| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // line. We just care about the last block. There is one trailing empty | 154 // line. We just care about the last block. There is one trailing empty |
| 155 // line, though, which we don't want to consider a separator. | 155 // line, though, which we don't want to consider a separator. |
| 156 var lastBlank = lines.lastIndexOf("", lines.length - 2); | 156 var lastBlank = lines.lastIndexOf("", lines.length - 2); |
| 157 if (lastBlank != -1) lines.removeRange(0, lastBlank + 1); | 157 if (lastBlank != -1) lines.removeRange(0, lastBlank + 1); |
| 158 | 158 |
| 159 var statusParts = lines.removeAt(0).split(" "); | 159 var statusParts = lines.removeAt(0).split(" "); |
| 160 var status = int.parse(statusParts[1]); | 160 var status = int.parse(statusParts[1]); |
| 161 var isRedirect = status >= 300 && status < 400; | 161 var isRedirect = status >= 300 && status < 400; |
| 162 var reasonPhrase = | 162 var reasonPhrase = |
| 163 Strings.join(statusParts.getRange(2, statusParts.length - 2), " "); | 163 Strings.join(statusParts.getRange(2, statusParts.length - 2), " "); |
| 164 var headers = <String, String>{}; | 164 var headers = {}; |
| 165 for (var line in lines) { | 165 for (var line in lines) { |
| 166 if (line.isEmpty) continue; | 166 if (line.isEmpty) continue; |
| 167 var split = split1(line, ":"); | 167 var split = split1(line, ":"); |
| 168 headers[split[0].toLowerCase()] = split[1].trim(); | 168 headers[split[0].toLowerCase()] = split[1].trim(); |
| 169 } | 169 } |
| 170 var responseStream = process.stdout; | 170 var responseStream = process.stdout; |
| 171 if (responseStream.closed) { | 171 if (responseStream.closed) { |
| 172 responseStream = new ListInputStream(); | 172 responseStream = new ListInputStream(); |
| 173 responseStream.markEndOfStream(); | 173 responseStream.markEndOfStream(); |
| 174 } | 174 } |
| (...skipping 14 matching lines...) Expand all 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 |