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

Unified Diff: pkg/shelf/test/shelf_io_test.dart

Issue 654933005: pkg/shelf: handle errors when parsing HttpRequest in shelf_io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nit Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/shelf/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf/test/shelf_io_test.dart
diff --git a/pkg/shelf/test/shelf_io_test.dart b/pkg/shelf/test/shelf_io_test.dart
index b3b43258a98458f6443735655757270709240db4..c1b4a410cd5fa9c5a0688de38d2a7f2b7dd8b5f1 100644
--- a/pkg/shelf/test/shelf_io_test.dart
+++ b/pkg/shelf/test/shelf_io_test.dart
@@ -251,6 +251,35 @@ void main() {
});
});
+ test('a bad HTTP request results in a 500 response', () {
+ var socket;
+
+ _scheduleServer(syncHandler);
+
+ schedule(() {
+ return Socket.connect('localhost', _serverPort).then((value) {
+ socket = value;
+
+ currentSchedule.onComplete.schedule(() {
+ return socket.close();
+ }, 'close the socket');
+ });
+ });
+
+ schedule(() {
+ socket.write('GET / HTTP/1.1\r\n');
+ socket.write('Host: ^^super bad !@#host\r\n');
+ socket.write('\r\n');
+ return socket.close();
+ });
+
+ schedule(() {
+ return UTF8.decodeStream(socket).then((value) {
+ expect(value, contains('500 Internal Server Error'));
+ });
+ });
+ });
+
group('date header', () {
test('is sent by default', () {
_scheduleServer(syncHandler);
« no previous file with comments | « pkg/shelf/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698