diff options
Diffstat (limited to 'textproto')
-rw-r--r-- | textproto/mod.ts | 20 | ||||
-rw-r--r-- | textproto/reader_test.ts | 10 |
2 files changed, 15 insertions, 15 deletions
diff --git a/textproto/mod.ts b/textproto/mod.ts index 419a57b68..941525e95 100644 --- a/textproto/mod.ts +++ b/textproto/mod.ts @@ -3,7 +3,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -import { BufReader, EOF, UnexpectedEOFError } from "../io/bufio.ts"; +import { BufReader, UnexpectedEOFError } from "../io/bufio.ts"; import { charCode } from "../io/util.ts"; const asciiDecoder = new TextDecoder(); @@ -39,9 +39,9 @@ export class TextProtoReader { /** readLine() reads a single line from the TextProtoReader, * eliding the final \n or \r\n from the returned string. */ - async readLine(): Promise<string | EOF> { + async readLine(): Promise<string | Deno.EOF> { const s = await this.readLineSlice(); - if (s === EOF) return EOF; + if (s === Deno.EOF) return Deno.EOF; return str(s); } @@ -65,20 +65,20 @@ export class TextProtoReader { * "Long-Key": {"Even Longer Value"}, * } */ - async readMIMEHeader(): Promise<Headers | EOF> { + async readMIMEHeader(): Promise<Headers | Deno.EOF> { let m = new Headers(); let line: Uint8Array; // The first line cannot start with a leading space. let buf = await this.r.peek(1); - if (buf === EOF) { - return EOF; + if (buf === Deno.EOF) { + return Deno.EOF; } else if (buf[0] == charCode(" ") || buf[0] == charCode("\t")) { line = (await this.readLineSlice()) as Uint8Array; } buf = await this.r.peek(1); - if (buf === EOF) { + if (buf === Deno.EOF) { throw new UnexpectedEOFError(); } else if (buf[0] == charCode(" ") || buf[0] == charCode("\t")) { throw new ProtocolError( @@ -88,7 +88,7 @@ export class TextProtoReader { while (true) { let kv = await this.readLineSlice(); // readContinuedLineSlice - if (kv === EOF) throw new UnexpectedEOFError(); + if (kv === Deno.EOF) throw new UnexpectedEOFError(); if (kv.byteLength === 0) return m; // Key ends at first colon; should not have trailing spaces @@ -133,12 +133,12 @@ export class TextProtoReader { } } - async readLineSlice(): Promise<Uint8Array | EOF> { + async readLineSlice(): Promise<Uint8Array | Deno.EOF> { // this.closeDot(); let line: Uint8Array; while (true) { const r = await this.r.readLine(); - if (r === EOF) return EOF; + if (r === Deno.EOF) return Deno.EOF; const { line: l, more } = r; // Avoid the copy if the first call produced a full line. diff --git a/textproto/reader_test.ts b/textproto/reader_test.ts index 2b81685a2..adfb0c962 100644 --- a/textproto/reader_test.ts +++ b/textproto/reader_test.ts @@ -3,7 +3,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -import { BufReader, EOF } from "../io/bufio.ts"; +import { BufReader } from "../io/bufio.ts"; import { TextProtoReader, ProtocolError } from "./mod.ts"; import { stringsReader } from "../io/util.ts"; import { @@ -14,8 +14,8 @@ import { } from "../testing/asserts.ts"; import { test, runIfMain } from "../testing/mod.ts"; -function assertNotEOF<T extends {}>(val: T | EOF): T { - assertNotEquals(val, EOF); +function assertNotEOF<T extends {}>(val: T | Deno.EOF): T { + assertNotEquals(val, Deno.EOF); return val as T; } @@ -33,7 +33,7 @@ function reader(s: string): TextProtoReader { test(async function textprotoReadEmpty(): Promise<void> { const r = reader(""); const m = await r.readMIMEHeader(); - assertEquals(m, EOF); + assertEquals(m, Deno.EOF); }); test(async function textprotoReader(): Promise<void> { @@ -45,7 +45,7 @@ test(async function textprotoReader(): Promise<void> { assertEquals(s, "line2"); s = await r.readLine(); - assert(s === EOF); + assert(s === Deno.EOF); }); test({ |