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

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

Issue 11821062: Don't die because we write empty arrays to cURL. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « no previous file | 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 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 20 matching lines...) Expand all
31 : executable = executable == null ? _defaultExecutable : executable; 31 : executable = executable == null ? _defaultExecutable : executable;
32 32
33 /// Sends a request via `curl` and returns the response. 33 /// Sends a request via `curl` and returns the response.
34 Future<http.StreamedResponse> send(http.BaseRequest request) { 34 Future<http.StreamedResponse> send(http.BaseRequest request) {
35 log.fine("Sending Curl request $request"); 35 log.fine("Sending Curl request $request");
36 36
37 var requestStream = request.finalize(); 37 var requestStream = request.finalize();
38 return withTempDir((tempDir) { 38 return withTempDir((tempDir) {
39 var headerFile = join(tempDir, "curl-headers"); 39 var headerFile = join(tempDir, "curl-headers");
40 var arguments = _argumentsForRequest(request, headerFile); 40 var arguments = _argumentsForRequest(request, headerFile);
41 log.process(executable, arguments);
42 var process; 41 var process;
43 return startProcess(executable, arguments).then((process_) { 42 return startProcess(executable, arguments).then((process_) {
44 process = process_; 43 process = process_;
45 return requestStream.pipe(wrapOutputStream(process.stdin)); 44 return requestStream.pipe(wrapOutputStream(process.stdin));
46 }).then((_) { 45 }).then((_) {
47 return _waitForHeaders(process, expectBody: request.method != "HEAD"); 46 return _waitForHeaders(process, expectBody: request.method != "HEAD");
48 }).then((_) => new File(headerFile).readAsLines()) 47 }).then((_) => new File(headerFile).readAsLines())
49 .then((lines) => _buildResponse(request, process, lines)); 48 .then((lines) => _buildResponse(request, process, lines));
50 }); 49 });
51 } 50 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 /// 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
191 /// assume it to be installed and on the user's PATH. 190 /// assume it to be installed and on the user's PATH.
192 static String get _defaultExecutable { 191 static String get _defaultExecutable {
193 if (Platform.operatingSystem != 'windows') return 'curl'; 192 if (Platform.operatingSystem != 'windows') return 'curl';
194 // 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
195 // relative path to curl in the SDK. 194 // relative path to curl in the SDK.
196 var pathToCurl = "../../third_party/curl/curl.exe"; 195 var pathToCurl = "../../third_party/curl/curl.exe";
197 return relativeToPub(pathToCurl); 196 return relativeToPub(pathToCurl);
198 } 197 }
199 } 198 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698