Chromium Code Reviews| 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 io_client; | 5 library io_client; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'base_client.dart'; | 10 import 'base_client.dart'; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 underlyingRequest.headers.set(name, value); | 50 underlyingRequest.headers.set(name, value); |
| 51 }); | 51 }); |
| 52 | 52 |
| 53 chainToCompleter( | 53 chainToCompleter( |
| 54 stream.pipe(wrapOutputStream(underlyingRequest.outputStream)), | 54 stream.pipe(wrapOutputStream(underlyingRequest.outputStream)), |
| 55 pipeCompleter); | 55 pipeCompleter); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 connection.onResponse = (response) { | 58 connection.onResponse = (response) { |
| 59 var headers = {}; | 59 var headers = {}; |
| 60 response.headers.forEach((key, value) => headers[key] = value); | 60 response.headers.forEach((key, values) { |
| 61 headers[key] = Strings.join(values, ','); | |
|
Bob Nystrom
2013/01/29 23:51:54
values.join(',')
lib_v2 is like living IN THE FUT
| |
| 62 }); | |
| 61 | 63 |
| 62 if (completed) return; | 64 if (completed) return; |
| 63 | 65 |
| 64 completed = true; | 66 completed = true; |
| 65 completer.complete(new StreamedResponse( | 67 completer.complete(new StreamedResponse( |
| 66 wrapInputStream(response.inputStream), | 68 wrapInputStream(response.inputStream), |
| 67 response.statusCode, | 69 response.statusCode, |
| 68 response.contentLength, | 70 response.contentLength, |
| 69 request: request, | 71 request: request, |
| 70 headers: headers, | 72 headers: headers, |
| 71 isRedirect: response.isRedirect, | 73 isRedirect: response.isRedirect, |
| 72 persistentConnection: response.persistentConnection, | 74 persistentConnection: response.persistentConnection, |
| 73 reasonPhrase: response.reasonPhrase)); | 75 reasonPhrase: response.reasonPhrase)); |
| 74 }; | 76 }; |
| 75 | 77 |
| 76 return Future.wait([ | 78 return Future.wait([ |
| 77 completer.future, | 79 completer.future, |
| 78 pipeCompleter.future | 80 pipeCompleter.future |
| 79 ]).then((values) => values.first); | 81 ]).then((values) => values.first); |
| 80 } | 82 } |
| 81 | 83 |
| 82 /// Closes the client. This terminates all active connections. If a client | 84 /// Closes the client. This terminates all active connections. If a client |
| 83 /// remains unclosed, the Dart process may not terminate. | 85 /// remains unclosed, the Dart process may not terminate. |
| 84 void close() { | 86 void close() { |
| 85 if (_inner != null) _inner.shutdown(force: true); | 87 if (_inner != null) _inner.shutdown(force: true); |
| 86 _inner = null; | 88 _inner = null; |
| 87 } | 89 } |
| 88 } | 90 } |
| OLD | NEW |