From 209183e24812095a40e48e60484f80a5a254b1c3 Mon Sep 17 00:00:00 2001 From: Vincent LE GOFF Date: Wed, 22 May 2019 15:30:10 +0200 Subject: [PATCH] http: delete conn parameter in readRequest (#430) To bring it inline with Go API --- http/server.ts | 8 +++----- http/server_test.ts | 15 --------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/http/server.ts b/http/server.ts index da335a58cd..3886e76726 100644 --- a/http/server.ts +++ b/http/server.ts @@ -104,7 +104,6 @@ export class ServerRequest { method: string; proto: string; headers: Headers; - conn: Conn; r: BufReader; w: BufWriter; done: Deferred = deferred(); @@ -199,13 +198,10 @@ export class ServerRequest { } async function readRequest( - conn: Conn, bufr: BufReader ): Promise<[ServerRequest, BufState]> { const req = new ServerRequest(); - req.conn = conn; req.r = bufr; - req.w = new BufWriter(conn); const tp = new TextProtoReader(bufr); let err: BufState; // First line: GET /index.html HTTP/1.0 @@ -234,12 +230,14 @@ export class Server implements AsyncIterable { conn: Conn ): AsyncIterableIterator { const bufr = new BufReader(conn); + const w = new BufWriter(conn); let bufStateErr: BufState; let req: ServerRequest; while (!this.closing) { - [req, bufStateErr] = await readRequest(conn, bufr); + [req, bufStateErr] = await readRequest(bufr); if (bufStateErr) break; + req.w = w; yield req; // Wait for the request to be processed before we accept a new request on // this connection. diff --git a/http/server_test.ts b/http/server_test.ts index 396a0321a1..a2a4713d90 100644 --- a/http/server_test.ts +++ b/http/server_test.ts @@ -49,21 +49,6 @@ test(async function responseWrite(): Promise { const request = new ServerRequest(); request.w = bufw; - request.conn = { - localAddr: "", - remoteAddr: "", - rid: -1, - closeRead: (): void => {}, - closeWrite: (): void => {}, - read: async (): Promise => { - return { eof: true, nread: 0 }; - }, - write: async (): Promise => { - return -1; - }, - close: (): void => {} - }; - await request.respond(testCase.response); assertEquals(buf.toString(), testCase.raw); await request.done;