| OLD | NEW | 
|---|
| 1 // Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 safe_http_server; | 5 library safe_http_server; | 
| 6 | 6 | 
| 7 import 'dart:async'; | 7 import 'dart:async'; | 
| 8 import 'dart:io'; | 8 import 'dart:io'; | 
| 9 import 'dart:uri'; | 9 import 'dart:uri'; | 
| 10 | 10 | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 36   int get port => _inner.port; | 36   int get port => _inner.port; | 
| 37 | 37 | 
| 38   set sessionTimeout(int timeout) { | 38   set sessionTimeout(int timeout) { | 
| 39     _inner.sessionTimeout = timeout; | 39     _inner.sessionTimeout = timeout; | 
| 40   } | 40   } | 
| 41 | 41 | 
| 42   HttpConnectionsInfo connectionsInfo() => _inner.connectionsInfo(); | 42   HttpConnectionsInfo connectionsInfo() => _inner.connectionsInfo(); | 
| 43 | 43 | 
| 44   StreamSubscription<HttpRequest> listen(void onData(HttpRequest value), | 44   StreamSubscription<HttpRequest> listen(void onData(HttpRequest value), | 
| 45       {void onError(AsyncError error), void onDone(), | 45       {void onError(AsyncError error), void onDone(), | 
| 46       bool unsubscribeOnError: false}) { | 46       bool cancelOnError: false}) { | 
| 47     var subscription; | 47     var subscription; | 
| 48     subscription = super.listen((request) { | 48     subscription = super.listen((request) { | 
| 49       onData(new _HttpRequestWrapper(request)); | 49       onData(new _HttpRequestWrapper(request)); | 
| 50     }, onError: (e) { | 50     }, onError: (e) { | 
| 51       var error = e.error; | 51       var error = e.error; | 
| 52       // Ignore socket error 104, which is caused by a request being cancelled | 52       // Ignore socket error 104, which is caused by a request being cancelled | 
| 53       // before it writes any headers. There's no reason to care about such | 53       // before it writes any headers. There's no reason to care about such | 
| 54       // requests. | 54       // requests. | 
| 55       if (error is SocketIOException && error.osError.errorCode == 104) return; | 55       if (error is SocketIOException && error.osError.errorCode == 104) return; | 
| 56       // Ignore any parsing errors, which come from malformed requests. | 56       // Ignore any parsing errors, which come from malformed requests. | 
| 57       if (error is HttpParserException) return; | 57       if (error is HttpParserException) return; | 
| 58       // Manually handle unsubscribeOnError so the above (ignored) errors don't | 58       // Manually handle cancelOnError so the above (ignored) errors don't | 
| 59       // cause unsubscription. | 59       // cause unsubscription. | 
| 60       if (unsubscribeOnError) subscription.cancel(); | 60       if (cancelOnError) subscription.cancel(); | 
| 61       if (onError != null) onError(e); | 61       if (onError != null) onError(e); | 
| 62     }, onDone: onDone); | 62     }, onDone: onDone); | 
| 63     return subscription; | 63     return subscription; | 
| 64   } | 64   } | 
| 65 } | 65 } | 
| 66 | 66 | 
| 67 /// A wrapper around [HttpRequest] for the sole purpose of swallowing errors on | 67 /// A wrapper around [HttpRequest] for the sole purpose of swallowing errors on | 
| 68 /// [HttpResponse.done]. | 68 /// [HttpResponse.done]. | 
| 69 class _HttpRequestWrapper extends StreamView<List<int>> implements HttpRequest { | 69 class _HttpRequestWrapper extends StreamView<List<int>> implements HttpRequest { | 
| 70   final HttpRequest _inner; | 70   final HttpRequest _inner; | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 133   HttpConnectionInfo get connectionInfo => _inner.connectionInfo; | 133   HttpConnectionInfo get connectionInfo => _inner.connectionInfo; | 
| 134   void add(List<int> data) => _inner.add(data); | 134   void add(List<int> data) => _inner.add(data); | 
| 135   Future<HttpResponse> addStream(Stream<List<int>> stream) => | 135   Future<HttpResponse> addStream(Stream<List<int>> stream) => | 
| 136     _inner.addStream(stream); | 136     _inner.addStream(stream); | 
| 137   Future close() => _inner.close(); | 137   Future close() => _inner.close(); | 
| 138   void write(Object obj) => _inner.write(obj); | 138   void write(Object obj) => _inner.write(obj); | 
| 139   void writeAll(Iterable objects) => _inner.writeAll(objects); | 139   void writeAll(Iterable objects) => _inner.writeAll(objects); | 
| 140   void writeCharCode(int charCode) => _inner.writeCharCode(charCode); | 140   void writeCharCode(int charCode) => _inner.writeCharCode(charCode); | 
| 141   void writeln([Object obj = ""]) => _inner.writeln(obj); | 141   void writeln([Object obj = ""]) => _inner.writeln(obj); | 
| 142 } | 142 } | 
| OLD | NEW | 
|---|