message body
The data carried after the headers in an HTTP request or response, such as a JSON document.
In more detail
Headers such as Content-Type and Content-Length describe it. Clients should read it as a stream, cap how much they accept from untrusted servers and release it when done.
Example
defer resp.Body.Close()Related terms
- HTTP response — The message a server sends back: a protocol version, a status code and phrase, headers, a blank line and usually a body.
- io.Reader — The Go interface for anything you can read bytes from, such as a file, a network connection or an HTTP response body.
- defer — A Go statement that schedules a function call to run when the surrounding function returns, used for cleanup such as closing a file.
- io.LimitReader — The Go function that wraps an io.Reader so it stops after a set number of bytes, capping how much you will read.
- file descriptor — A small number the operating system gives a process for each open file, socket or pipe, used in every later read or write.
- HTTP header — A named line of metadata in an HTTP message, such as Content-Type: application/json, that describes the body, the caller or how to handle the exchange.
- payload — The actual data a message carries, as opposed to the headers and framing around it.
- stream — Data that flows between a program and a source or destination piece by piece, rather than all at once.
Taught in
- Streams and the io Package — Concurrent Systems Programming with Go
- Calling APIs with net/http Client — Concurrent Systems Programming with Go
- Native HTTP Server: Request & Response Lifecycles — Node.js Internals & Backend Services