HTTP response
The message a server sends back: a protocol version, a status code and phrase, headers, a blank line and usually a body.
In more detail
Read every answer in that order: the status says what happened, the headers describe the body and how to treat it, and the body carries the representation or a problem document. In HTTP/1.1 the start line looks like HTTP/1.1 200 OK.
Examples
In the APIs course: The course calls this reading an answer as status, headers, body.fmt.Println(response.StatusCode)Go: resp.StatusCode, resp.Header, resp.BodyThe status code gives the broad outcome and the headers describe the body, caching and more. Read the headers before assuming the body holds the whole reason for a failure.Related terms
- HTTP request — The message a client sends to a server: a method, a target, a protocol version, headers, a blank line and an optional body.
- HTTP status code — The three-digit number at the start of a response, such as 200 or 404, that says how the server handled the request.
- 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.
- message body — The data carried after the headers in an HTTP request or response, such as a JSON document.
- http.Client — The Go type that sends HTTP requests and returns responses, managing connections and timeouts for you.
Taught in
- What An API Is, And The Alternatives — Modern API Architecture: REST, GraphQL & gRPC
- HTTP Methods And Status Codes — Modern API Architecture: REST, GraphQL & gRPC
- Calling APIs with net/http Client — Concurrent Systems Programming with Go
- HTTP Is Text: Requests, Status Codes And Headers — Linux Fundamentals & Systems Administration