Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-netboot-physical FR-004
The HTTP server of the boot machine, on node:http. Firmware and GRUB are picky clients: GRUB's HTTP client compares Content-Length: case-sensitively and reads every file as empty if the name is in lower case, and sends HEAD and then GET on one connection. So the header names are written in their canonical case, connections are kept alive, and a file is streamed (an installer image is several GB) with Range for a resumed download. The handler is a function of a plain request to a plain response.
import { httpServer } from "./http-server.ts" ;
// const s = await httpServer({ port: 0, handle: async () => ({ status: 200, headers: {}, body: "ok" }) }); await s.stop(); Source: commons/netboot/src/physical/http-server.ts
2 of 14 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.
physical.BootRequesttype no test imports it type BootRequest = { readonly method : string ; readonly path : string ; readonly host : string ; readonly from : string ; readonly range : string | undefined ; readonly body : Uint8Array };A request, as the handler sees it.
physical.BootBodytype no test imports it type BootBody = string | Uint8Array | { readonly file : string ; readonly size : number };What a response carries: text or bytes, or a file to stream.
physical.BootResponsetype no test imports it type BootResponse = { readonly status : number ; readonly headers : Readonly <Record <string , string >>; readonly body : BootBody };physical.HttpOptionstype no test imports it type HttpOptions = { readonly port : number ; readonly hostname ?: string ; readonly handle : (r : BootRequest ) => Promise <BootResponse > };What the server is given.
physical.HttpServertype no test imports it type HttpServer = { readonly port : number ; stop (): Promise <void > };physical.parseRangefunction no test imports it function parseRange (header : string | undefined , size : number ): "none" | "unsatisfiable" | { readonly start : number ; readonly end : number ; }The byte range a Range: bytes=a-b asks of a file of size bytes, or why it cannot be given.
physical.httpServerfunction no test imports it function httpServer (o : HttpOptions ): Promise <HttpServer >BootRequesttype no test imports it type BootRequest = { readonly method : string ; readonly path : string ; readonly host : string ; readonly from : string ; readonly range : string | undefined ; readonly body : Uint8Array };A request, as the handler sees it.
BootBodytype no test imports it type BootBody = string | Uint8Array | { readonly file : string ; readonly size : number };What a response carries: text or bytes, or a file to stream.
BootResponsetype no test imports it type BootResponse = { readonly status : number ; readonly headers : Readonly <Record <string , string >>; readonly body : BootBody };HttpOptionstype no test imports it type HttpOptions = { readonly port : number ; readonly hostname ?: string ; readonly handle : (r : BootRequest ) => Promise <BootResponse > };What the server is given.
HttpServertype no test imports it type HttpServer = { readonly port : number ; stop (): Promise <void > };function parseRange (header : string | undefined , size : number ): "none" | "unsatisfiable" | { readonly start : number ; readonly end : number ; }The byte range a Range: bytes=a-b asks of a file of size bytes, or why it cannot be given.
Imported by 18 tests of the run (18 passed, 0 failed): the library's results
function httpServer (o : HttpOptions ): Promise <HttpServer >Starts the server.
Imported by 18 tests of the run (18 passed, 0 failed): the library's results