| Index: runtime/bin/http_impl.dart
|
| diff --git a/runtime/bin/http_impl.dart b/runtime/bin/http_impl.dart
|
| index 5d5eb534b3c13595db9fbe7f49e623378cb9e570..45b5c8b205949501d9677bb9626261ea53f59ce6 100644
|
| --- a/runtime/bin/http_impl.dart
|
| +++ b/runtime/bin/http_impl.dart
|
| @@ -369,7 +369,7 @@ class _HttpRequest extends _HttpRequestResponseBase implements HttpRequest {
|
| buffer.setRange(offset, data.length, data);
|
| }
|
|
|
| - void _streamSetErrorHandler(callback(Exception e)) {
|
| + void _streamSetErrorHandler(callback(e)) {
|
| _streamErrorHandler = callback;
|
| }
|
|
|
| @@ -457,7 +457,7 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
|
| // TODO(sgjesse): Handle this.
|
| }
|
|
|
| - void _streamSetErrorHandler(callback(Exception e)) {
|
| + void _streamSetErrorHandler(callback(e)) {
|
| _streamErrorHandler = callback;
|
| }
|
|
|
| @@ -583,7 +583,7 @@ class _HttpInputStream extends _BaseDataInputStream implements InputStream {
|
| return result;
|
| }
|
|
|
| - void set onError(void callback(Exception e)) {
|
| + void set onError(void callback(e)) {
|
| _requestOrResponse._streamSetErrorHandler(callback);
|
| }
|
|
|
| @@ -632,7 +632,7 @@ class _HttpOutputStream extends _BaseOutputStream implements OutputStream {
|
| _requestOrResponse._streamSetCloseHandler(callback);
|
| }
|
|
|
| - void set onError(void callback(Exception e)) {
|
| + void set onError(void callback(e)) {
|
| _requestOrResponse._streamSetErrorHandler(callback);
|
| }
|
|
|
| @@ -650,6 +650,9 @@ class _HttpConnectionBase implements Hashable {
|
| _socket.onData = _onData;
|
| _socket.onClosed = _onClosed;
|
| _socket.onError = _onError;
|
| + // Ignore errors in the socket output stream as this is getting
|
| + // the same errors as the socket itself.
|
| + _socket.outputStream.onError = (e) => null;
|
| }
|
|
|
| bool _write(List<int> data, [bool copyBuffer = false]) {
|
| @@ -691,7 +694,7 @@ class _HttpConnectionBase implements Hashable {
|
| _onConnectionClosed(null);
|
| }
|
|
|
| - void _onError(Exception e) {
|
| + void _onError(e) {
|
| // If an error occurs, make sure to close the socket if one is associated.
|
| _error = true;
|
| if (_socket != null) {
|
| @@ -700,7 +703,7 @@ class _HttpConnectionBase implements Hashable {
|
| _onConnectionClosed(e);
|
| }
|
|
|
| - abstract void _onConnectionClosed(Exception e);
|
| + abstract void _onConnectionClosed(e);
|
| abstract void _responseDone();
|
|
|
| void set _onNoPendingWrites(void callback()) {
|
| @@ -737,8 +740,11 @@ class _HttpConnection extends _HttpConnectionBase {
|
| _httpParser.error = (e) => _onError(e);
|
| }
|
|
|
| - void _onConnectionClosed(Exception e) {
|
| - if (e != null && onError != null) {
|
| + void _onConnectionClosed(e) {
|
| + // Don't report errors when HTTP parser is in idle state. Clients
|
| + // can close the connection and cause a connection reset by peer
|
| + // error which is OK.
|
| + if (e != null && onError != null && !_httpParser.isIdle) {
|
| onError(e);
|
| // Propagate the error to the streams.
|
| if (_request != null && _request._streamErrorHandler != null) {
|
| @@ -856,7 +862,11 @@ class _HttpServer implements HttpServer {
|
| connection.onClosed = () => _connections.remove(connection);
|
| connection.onError = (e) {
|
| _connections.remove(connection);
|
| - if (_onError != null) _onError(e);
|
| + if (_onError != null) {
|
| + _onError(e);
|
| + } else {
|
| + throw(e);
|
| + }
|
| };
|
| connection._connectionEstablished(socket);
|
| _connections.add(connection);
|
| @@ -895,7 +905,7 @@ class _HttpServer implements HttpServer {
|
| return _server.port;
|
| }
|
|
|
| - void set onError(void callback(Exception e)) {
|
| + void set onError(void callback(e)) {
|
| _onError = callback;
|
| }
|
|
|
| @@ -908,6 +918,8 @@ class _HttpServer implements HttpServer {
|
| } catch (var e) {
|
| if (_onError != null) {
|
| _onError(e);
|
| + } else {
|
| + throw e;
|
| }
|
| }
|
| return;
|
| @@ -995,7 +1007,7 @@ class _HttpClientRequest
|
| // TODO(sgjesse): Handle this.
|
| }
|
|
|
| - void _streamSetErrorHandler(callback(Exception e)) {
|
| + void _streamSetErrorHandler(callback(e)) {
|
| _streamErrorHandler = callback;
|
| }
|
|
|
| @@ -1096,7 +1108,7 @@ class _HttpClientResponse
|
| return data.length;
|
| }
|
|
|
| - void _streamSetErrorHandler(callback(Exception e)) {
|
| + void _streamSetErrorHandler(callback(e)) {
|
| _streamErrorHandler = callback;
|
| }
|
|
|
| @@ -1152,7 +1164,7 @@ class _HttpClientConnection
|
| return _request;
|
| }
|
|
|
| - void _onConnectionClosed(Exception e) {
|
| + void _onConnectionClosed(e) {
|
| // Socket is closed either due to an error or due to normal socket close.
|
| if (e != null) {
|
| if (_onErrorCallback != null) {
|
| @@ -1207,7 +1219,7 @@ class _HttpClientConnection
|
| _onResponse = handler;
|
| }
|
|
|
| - void set onError(void callback(Exception e)) {
|
| + void set onError(void callback(e)) {
|
| _onErrorCallback = callback;
|
| }
|
|
|
| @@ -1343,7 +1355,7 @@ class _HttpClient implements HttpClient {
|
| // Until the connection is established handle connection errors
|
| // here as the HttpClientConnection object is not yet associated
|
| // with the socket.
|
| - socket.onError = (Exception e) {
|
| + socket.onError = (e) {
|
| // Report the error through the HttpClientConnection object to
|
| // the client.
|
| connection._onError(e);
|
|
|