From c8fc29fcca0171166b7093d278bfbe03d970f1a5 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 2 Apr 2020 15:20:17 -0400 Subject: Revert "Respond with 400 on request parse failure" (#4593) readRequest should not write a response. This reverts commit 017a611131a35ccf5dbfce6a2a665fa569e32ec1. --- std/http/io_test.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'std/http/io_test.ts') diff --git a/std/http/io_test.ts b/std/http/io_test.ts index aa9c86130..768a4ffe4 100644 --- a/std/http/io_test.ts +++ b/std/http/io_test.ts @@ -5,7 +5,6 @@ import { assert, assertNotEOF, assertNotEquals, - assertMatch, } from "../testing/asserts.ts"; import { bodyReader, @@ -350,28 +349,13 @@ malformedHeader `; const reader = new BufReader(new StringReader(input)); let err; - let responseString: string; try { - // Capture whatever `readRequest()` attempts to write to the connection on - // error. We expect it to be a 400 response. - await readRequest( - mockConn({ - write(p: Uint8Array): Promise { - responseString = decode(p); - return Promise.resolve(p.length); - }, - }), - reader - ); + await readRequest(mockConn(), reader); } catch (e) { err = e; } assert(err instanceof Error); assertEquals(err.message, "malformed MIME header line: malformedHeader"); - assertMatch( - responseString!, - /^HTTP\/1\.1 400 Bad Request\r\ncontent-length: \d+\r\n\r\n.*\r\n\r\n$/ms - ); }); // Ported from Go -- cgit v1.2.3