HTTP client errors shouldn't be sent to both the connection and the input stream #7014
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-io
Milestone
Currently, if an error happens in an HttpClientConnection, it's passed to the onError callbacks of both the connection itself and the InputStream of the HttpClientResponse, should such a thing exist. Here's a simple reproduction:
void main() {
var client = new HttpClient();
var url = new Uri.fromString("http://pub.dartlang.org");
var connection = client.openUrl("GET", url);
connection.onError = (e) => print("connection error: $e");
connection.onRequest = (request) {
request.outputStream.onError = (e) => print("request stream error: $e");
request.outputStream.close();
};
connection.onResponse = (response) {
response.inputStream.onData = response.inputStream.read;
response.inputStream.onError = (e) => print("response stream error: $e");
response.inputStream.onClosed = () => print("response stream closed");
print("response headers received");
client.shutdown(force: true);
};
}
The text was updated successfully, but these errors were encountered: