summaryrefslogtreecommitdiff
path: root/std/http
diff options
context:
space:
mode:
Diffstat (limited to 'std/http')
-rwxr-xr-xstd/http/file_server.ts10
-rw-r--r--std/http/io.ts4
-rw-r--r--std/http/mock.ts8
-rw-r--r--std/http/server_test.ts2
4 files changed, 12 insertions, 12 deletions
diff --git a/std/http/file_server.ts b/std/http/file_server.ts
index 18a68aa49..20d5d61e6 100755
--- a/std/http/file_server.ts
+++ b/std/http/file_server.ts
@@ -158,17 +158,17 @@ async function serveDir(
return res;
}
-async function serveFallback(req: ServerRequest, e: Error): Promise<Response> {
+function serveFallback(req: ServerRequest, e: Error): Promise<Response> {
if (e instanceof Deno.errors.NotFound) {
- return {
+ return Promise.resolve({
status: 404,
body: encoder.encode("Not found")
- };
+ });
} else {
- return {
+ return Promise.resolve({
status: 500,
body: encoder.encode("Internal server error")
- };
+ });
}
}
diff --git a/std/http/io.ts b/std/http/io.ts
index 5518146a8..6d5d1f665 100644
--- a/std/http/io.ts
+++ b/std/http/io.ts
@@ -7,8 +7,8 @@ import { STATUS_TEXT } from "./http_status.ts";
export function emptyReader(): Deno.Reader {
return {
- async read(_: Uint8Array): Promise<number | Deno.EOF> {
- return Deno.EOF;
+ read(_: Uint8Array): Promise<number | Deno.EOF> {
+ return Promise.resolve(Deno.EOF);
}
};
}
diff --git a/std/http/mock.ts b/std/http/mock.ts
index 3a4eeed82..cee697bed 100644
--- a/std/http/mock.ts
+++ b/std/http/mock.ts
@@ -14,11 +14,11 @@ export function mockConn(base: Partial<Deno.Conn> = {}): Deno.Conn {
rid: -1,
closeRead: (): void => {},
closeWrite: (): void => {},
- read: async (): Promise<number | Deno.EOF> => {
- return 0;
+ read: (): Promise<number | Deno.EOF> => {
+ return Promise.resolve(0);
},
- write: async (): Promise<number> => {
- return -1;
+ write: (): Promise<number> => {
+ return Promise.resolve(-1);
},
close: (): void => {},
...base
diff --git a/std/http/server_test.ts b/std/http/server_test.ts
index 0a4986dcf..2a7c46134 100644
--- a/std/http/server_test.ts
+++ b/std/http/server_test.ts
@@ -68,7 +68,7 @@ test(async function responseWrite(): Promise<void> {
}
});
-test(async function requestContentLength(): Promise<void> {
+test(function requestContentLength(): void {
// Has content length
{
const req = new ServerRequest();