Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: pkg/http/test/safe_http_server.dart

Issue 16123036: Clean up dart:io exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/http/test/client_test.dart ('k') | pkg/http/test/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9
10 // TODO(nweiz): remove this when issue 9140 is fixed. 10 // TODO(nweiz): remove this when issue 9140 is fixed.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 StreamSubscription<HttpRequest> listen(void onData(HttpRequest value), 43 StreamSubscription<HttpRequest> listen(void onData(HttpRequest value),
44 {void onError(error), void onDone(), 44 {void onError(error), void onDone(),
45 bool cancelOnError: false}) { 45 bool cancelOnError: false}) {
46 var subscription; 46 var subscription;
47 subscription = super.listen((request) { 47 subscription = super.listen((request) {
48 onData(new _HttpRequestWrapper(request)); 48 onData(new _HttpRequestWrapper(request));
49 }, onError: (error) { 49 }, onError: (error) {
50 // Ignore socket error 104, which is caused by a request being cancelled 50 // Ignore socket error 104, which is caused by a request being cancelled
51 // before it writes any headers. There's no reason to care about such 51 // before it writes any headers. There's no reason to care about such
52 // requests. 52 // requests.
53 if (error is SocketIOException && error.osError.errorCode == 104) return; 53 if (error is SocketException && error.osError.errorCode == 104) return;
54 // Ignore any parsing errors, which come from malformed requests. 54 // Ignore any parsing errors, which come from malformed requests.
55 if (error is HttpParserException) return; 55 if (error is HttpException) return;
56 // Manually handle cancelOnError so the above (ignored) errors don't 56 // Manually handle cancelOnError so the above (ignored) errors don't
57 // cause unsubscription. 57 // cause unsubscription.
58 if (cancelOnError) subscription.cancel(); 58 if (cancelOnError) subscription.cancel();
59 if (onError != null) onError(error); 59 if (onError != null) onError(error);
60 }, onDone: onDone); 60 }, onDone: onDone);
61 return subscription; 61 return subscription;
62 } 62 }
63 } 63 }
64 64
65 /// A wrapper around [HttpRequest] for the sole purpose of swallowing errors on 65 /// A wrapper around [HttpRequest] for the sole purpose of swallowing errors on
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 Future<HttpResponse> addStream(Stream<List<int>> stream) => 132 Future<HttpResponse> addStream(Stream<List<int>> stream) =>
133 _inner.addStream(stream); 133 _inner.addStream(stream);
134 Future close() => _inner.close(); 134 Future close() => _inner.close();
135 void write(Object obj) => _inner.write(obj); 135 void write(Object obj) => _inner.write(obj);
136 void writeAll(Iterable objects, [String separator = ""]) => 136 void writeAll(Iterable objects, [String separator = ""]) =>
137 _inner.writeAll(objects, separator); 137 _inner.writeAll(objects, separator);
138 void writeCharCode(int charCode) => _inner.writeCharCode(charCode); 138 void writeCharCode(int charCode) => _inner.writeCharCode(charCode);
139 void writeln([Object obj = ""]) => _inner.writeln(obj); 139 void writeln([Object obj = ""]) => _inner.writeln(obj);
140 void addError(error) => _inner.addError(error); 140 void addError(error) => _inner.addError(error);
141 } 141 }
OLDNEW
« no previous file with comments | « pkg/http/test/client_test.dart ('k') | pkg/http/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698