IF Commons GitHub

logical/respond

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-anyfs-serve-logical FR-004

The answers: how a response is made, how the fidelity of a POSIX operation is written in X-Anyfs-Fidelity, and how an error of the POSIX view becomes a status. Every answer carries Cache-Control: no-store and X-Content-Type-Options: nosniff, and an answer made from a file carries Content-Security-Policy: sandbox, so that a browser that is pointed at the server cannot run a file as a page of the server.

import { fidelityHeader } from "./respond.ts";
fidelityHeader({ kind: "native" }); // "native"

Source: commons/anyfs-serve/src/logical/respond.ts

3 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

fidelityHeaderfunction
function fidelityHeader(f: Fidelity): string

A fidelity as the value of the header: native, emulated; reason=…; risk=… or refused; reason=….

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

Answertypeno test imports it
type Answer = {
  readonly status: Status;
  readonly headers?: Readonly<Record<string, string>>;
  readonly body?: Uint8Array | string | undefined;
  readonly fidelity?: Fidelity;
  /** The answer shows the content of a file. */
  readonly file?: boolean;
};

What an answer is made from.

responseOffunction
function responseOf(a: Answer): Response

The response of an answer.

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

xmlAnswerfunctionno test imports it
function xmlAnswer(status: 200 | 201 | 204 | 206 | 207 | 304 | 400 | 401 | 403 | 404 | 405 | 409 | 412 | 413 | 414 | 415 | 416 | 423 | 424 | 500 | 501 | 502 | 503, root: XmlElement, extra?: Readonly<Record<string, string>>, fidelity?: Fidelity | undefined): Answer

An answer whose body is XML.

textAnswerfunctionno test imports it
function textAnswer(status: 200 | 201 | 204 | 206 | 207 | 304 | 400 | 401 | 403 | 404 | 405 | 409 | 412 | 413 | 414 | 415 | 416 | 423 | 424 | 500 | 501 | 502 | 503, message: string, headers?: Readonly<Record<string, string>>, fidelity?: Fidelity | undefined): Answer

A plain answer that says what went wrong in a sentence.

errorAnswerfunction
function errorAnswer(e: PosixError, context: Context): Answer

The answer to an error of the POSIX view: the status of its code in the context, or 503 with a wait where the store is not there now, or 502 where what it holds is not what it says.

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.