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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 }, onError: (error) { | 50 }, onError: (error) { |
51 // Ignore socket error 104, which is caused by a request being cancelled | 51 // Ignore socket error 104, which is caused by a request being cancelled |
52 // before it writes any headers. There's no reason to care about such | 52 // before it writes any headers. There's no reason to care about such |
53 // requests. | 53 // requests. |
54 if (error is SocketIOException && error.osError.errorCode == 104) return; | 54 if (error is SocketIOException && error.osError.errorCode == 104) return; |
55 // Ignore any parsing errors, which come from malformed requests. | 55 // Ignore any parsing errors, which come from malformed requests. |
56 if (error is HttpParserException) return; | 56 if (error is HttpParserException) return; |
57 // Manually handle cancelOnError so the above (ignored) errors don't | 57 // Manually handle cancelOnError so the above (ignored) errors don't |
58 // cause unsubscription. | 58 // cause unsubscription. |
59 if (cancelOnError) subscription.cancel(); | 59 if (cancelOnError) subscription.cancel(); |
60 if (onError != null) onError(e); | 60 if (onError != null) onError(error); |
61 }, onDone: onDone); | 61 }, onDone: onDone); |
62 return subscription; | 62 return subscription; |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 /// A wrapper around [HttpRequest] for the sole purpose of swallowing errors on | 66 /// A wrapper around [HttpRequest] for the sole purpose of swallowing errors on |
67 /// [HttpResponse.done]. | 67 /// [HttpResponse.done]. |
68 class _HttpRequestWrapper extends StreamView<List<int>> implements HttpRequest { | 68 class _HttpRequestWrapper extends StreamView<List<int>> implements HttpRequest { |
69 final HttpRequest _inner; | 69 final HttpRequest _inner; |
70 final HttpResponse response; | 70 final HttpResponse response; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 HttpConnectionInfo get connectionInfo => _inner.connectionInfo; | 132 HttpConnectionInfo get connectionInfo => _inner.connectionInfo; |
133 void add(List<int> data) => _inner.add(data); | 133 void add(List<int> data) => _inner.add(data); |
134 Future<HttpResponse> addStream(Stream<List<int>> stream) => | 134 Future<HttpResponse> addStream(Stream<List<int>> stream) => |
135 _inner.addStream(stream); | 135 _inner.addStream(stream); |
136 Future close() => _inner.close(); | 136 Future close() => _inner.close(); |
137 void write(Object obj) => _inner.write(obj); | 137 void write(Object obj) => _inner.write(obj); |
138 void writeAll(Iterable objects, [String separator = ""]) => | 138 void writeAll(Iterable objects, [String separator = ""]) => |
139 _inner.writeAll(objects, separator); | 139 _inner.writeAll(objects, separator); |
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 void addError(error) => _inner.addError(error); |
142 } | 143 } |
OLD | NEW |