new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Deno · Reference · all subjects

api/http

4 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Deno.serveHttp() replaced with Deno.serve()

Deno.serveHttp() has been soft-removed as of Deno 2. Use Deno.serve() instead. Instead of const conn = Deno.listen({ port: 80 }); const httpConn = Deno.serveHttp(await conn.accept()); use Deno.serve({ port: 80 }, () => new Response("Hello World")).

Deno.Server renamed to Deno.HttpServer

Deno.Server type has been removed. Use Deno.HttpServer instead. Change function foo(server: Deno.Server) to function foo(server: Deno.HttpServer).

fetch API supports file: URLs for local files

Deno supports fetching file: URLs to read local files using the fetch API. Only absolute file URLs are supported; relative URLs like fetch("./some.json") will not work. To fetch a resource relative to the current module, use import.meta.url as the base: fetch(new URL("./config.json", import.meta.url)). Permissions: an appropriate --allow-read permission is required. Only GET method is supported for local files; other methods will reject the promise. Non-existent files reject with a vague TypeError to avoid fingerprinting attacks. No headers are set on the response. Response bodies are streamed from the Rust side, so large files are available in chunks and can be cancelled.

fetch spec deviations in Deno

Deno deviates from the WHATWG fetch specification in several ways: (1) No cookie jar; set-cookie headers are not processed or filtered from visible response headers. (2) No same-origin policy enforcement because Deno has no concept of origins. (3) Does not implement WHATWG fetch sections 3.1 (Origin header), 3.2 (CORS protocol), 3.5 (CORB), 3.6 (Cross-Origin-Resource-Policy header), or atomic HTTP redirect handling. (4) No opaqueredirect response type; redirect mode manual returns basic response instead. (5) Header guards are implemented but unlike browsers have no constraints on header names. (6) Not implemented: referrer, referrerPolicy, mode, credentials, cache, integrity, keepalive, and window properties in RequestInit. (7) priority member of RequestInit ("auto", "high", or "low") is accepted and validated but write-only, not exposed as property on Request object. (8) Request body upload streaming supported on HTTP/1.1 and HTTP/2, including duplex streaming. (9) set-cookie header is not concatenated when iterated over in headers iterator.

Give your agent this brain