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

Bun · all subjects

runtime/fetch

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

fetch() unix domain socket example GET request

Example of fetching over a unix domain socket: const unix = "/var/run/docker.sock"; const response = await fetch("http://localhost/info", { unix }); const body = await response.json(); console.log(body);

fetch() unix domain socket example POST request

Example of sending a POST request over a unix domain socket: const response = await fetch("https://hostname/a/path", { unix: "/var/run/path/to/unix.sock", method: "POST", body: JSON.stringify({ message: "Hello from Bun!" }), headers: { "Content-Type": "application/json" } }); const body = await response.json();

fetch() unix option for domain socket requests

The fetch() function in Bun accepts a unix option to send HTTP requests over a unix domain socket. The unix option value is the local file path to the unix domain socket. When unix is specified, fetch() sends the request over that socket instead of a TCP connection.

fetch() unix domain socket HTTPS support

HTTPS is supported when using fetch() with unix domain sockets. Use the https:// protocol in the URL instead of http:// when making HTTPS requests over a unix domain socket.

HTTP_PROXY and HTTPS_PROXY environment variables for global proxy

To use the same proxy for all fetch requests, set the $HTTP_PROXY or $HTTPS_PROXY environment variable to the proxy URL. This applies globally to all requests made in the process.

fetch() proxy example with basic URL

Example: await fetch("https://example.com", { proxy: "https://username:password@proxy.example.com:8080" });

fetch() proxy option accepts URL string, URL instance, or object

The proxy option in fetch() can be specified as a URL string, a URL instance, or an object with url and optional headers properties.

fetch() proxy example with custom headers

Example: await fetch("https://example.com", { proxy: { url: "https://proxy.example.com:8080", headers: { "Proxy-Authorization": "Bearer my-token", "X-Proxy-Region": "us-east-1" } } });

fetch() proxy URL can include username and password

The proxy URL can include username and password for authentication, in the format https://username:password@proxy.example.com:8080. It can use http:// or https:// protocol.

fetch() proxy object format with custom headers

The proxy option can be an object with the following structure: { url: string | URL, headers?: Record<string, string> | Headers }. The headers property accepts a plain object or a Headers instance and are sent directly to the proxy server in CONNECT requests for HTTPS targets or in the proxy request for HTTP targets.

fetch() Proxy-Authorization header overrides proxy URL credentials

If a Proxy-Authorization header is provided in the proxy object headers, it overrides any credentials included in the proxy URL.

Give your agent this brain