mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 06:20:13 +00:00
Don't die because we write empty arrays to cURL.
Review URL: https://codereview.chromium.org//11821062 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16941 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
ba1f89e2b0
commit
9c8eb660d5
2 changed files with 12 additions and 2 deletions
|
@ -38,7 +38,6 @@ class CurlClient extends http.BaseClient {
|
|||
return withTempDir((tempDir) {
|
||||
var headerFile = join(tempDir, "curl-headers");
|
||||
var arguments = _argumentsForRequest(request, headerFile);
|
||||
log.process(executable, arguments);
|
||||
var process;
|
||||
return startProcess(executable, arguments).then((process_) {
|
||||
process = process_;
|
||||
|
|
|
@ -599,7 +599,18 @@ class _OutputStreamConsumer implements StreamConsumer<List<int>, dynamic> {
|
|||
// the following TODO.
|
||||
var completed = false;
|
||||
var completer = new Completer();
|
||||
stream.listen((data) => _outputStream.write(data), onDone: () {
|
||||
stream.listen((data) {
|
||||
// Writing empty data to a closed stream can cause errors.
|
||||
if (data.isEmpty) return;
|
||||
|
||||
// TODO(nweiz): remove this try/catch when issue 7836 is fixed.
|
||||
try {
|
||||
_outputStream.write(data);
|
||||
} catch (e, stack) {
|
||||
if (!completed) completer.completeError(e, stack);
|
||||
completed = true;
|
||||
}
|
||||
}, onDone: () {
|
||||
_outputStream.close();
|
||||
// TODO(nweiz): wait until _outputStream.onClosed is called once issue
|
||||
// 7761 is fixed.
|
||||
|
|
Loading…
Reference in a new issue