diff options
author | Oliver Lenehan <sunsetkookaburra+github@outlook.com.au> | 2020-03-14 12:40:13 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-13 21:40:13 -0400 |
commit | 0f6acf275370cae09ffb3f6950a3926424f3b024 (patch) | |
tree | e77a2115394f36dcbd899fd8f2d5496ca7bde625 /std/http/io.ts | |
parent | aab1acaed163f91aa5e89b079c5312336abb2088 (diff) |
fix(std): Use Deno.errors where possible. (#4356)
Diffstat (limited to 'std/http/io.ts')
-rw-r--r-- | std/http/io.ts | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/std/http/io.ts b/std/http/io.ts index 477bab831..b53b52527 100644 --- a/std/http/io.ts +++ b/std/http/io.ts @@ -1,4 +1,4 @@ -import { BufReader, UnexpectedEOFError, BufWriter } from "../io/bufio.ts"; +import { BufReader, BufWriter } from "../io/bufio.ts"; import { TextProtoReader } from "../textproto/mod.ts"; import { assert } from "../testing/asserts.ts"; import { encoder } from "../strings/mod.ts"; @@ -57,13 +57,13 @@ export function chunkedBodyReader(h: Headers, r: BufReader): Deno.Reader { chunks.shift(); // Consume \r\n; if ((await tp.readLine()) === Deno.EOF) { - throw new UnexpectedEOFError(); + throw new Deno.errors.UnexpectedEof(); } } return readLength; } const line = await tp.readLine(); - if (line === Deno.EOF) throw new UnexpectedEOFError(); + if (line === Deno.EOF) throw new Deno.errors.UnexpectedEof(); // TODO: handle chunk extension const [chunkSizeString] = line.split(";"); const chunkSize = parseInt(chunkSizeString, 16); @@ -74,12 +74,12 @@ export function chunkedBodyReader(h: Headers, r: BufReader): Deno.Reader { if (chunkSize > buf.byteLength) { let eof = await r.readFull(buf); if (eof === Deno.EOF) { - throw new UnexpectedEOFError(); + throw new Deno.errors.UnexpectedEof(); } const restChunk = new Uint8Array(chunkSize - buf.byteLength); eof = await r.readFull(restChunk); if (eof === Deno.EOF) { - throw new UnexpectedEOFError(); + throw new Deno.errors.UnexpectedEof(); } else { chunks.push({ offset: 0, @@ -91,11 +91,11 @@ export function chunkedBodyReader(h: Headers, r: BufReader): Deno.Reader { const bufToFill = buf.subarray(0, chunkSize); const eof = await r.readFull(bufToFill); if (eof === Deno.EOF) { - throw new UnexpectedEOFError(); + throw new Deno.errors.UnexpectedEof(); } // Consume \r\n if ((await tp.readLine()) === Deno.EOF) { - throw new UnexpectedEOFError(); + throw new Deno.errors.UnexpectedEof(); } return chunkSize; } @@ -103,7 +103,7 @@ export function chunkedBodyReader(h: Headers, r: BufReader): Deno.Reader { assert(chunkSize === 0); // Consume \r\n if ((await r.readLine()) === Deno.EOF) { - throw new UnexpectedEOFError(); + throw new Deno.errors.UnexpectedEof(); } await readTrailers(h, r); finished = true; @@ -348,7 +348,7 @@ export async function readRequest( const firstLine = await tp.readLine(); // e.g. GET /index.html HTTP/1.0 if (firstLine === Deno.EOF) return Deno.EOF; const headers = await tp.readMIMEHeader(); - if (headers === Deno.EOF) throw new UnexpectedEOFError(); + if (headers === Deno.EOF) throw new Deno.errors.UnexpectedEof(); const req = new ServerRequest(); req.conn = conn; |