header(), bearerToken(), ip() and the negotiation helpers describe the request itself. ip() is the TCP peer unless trustProxies() (Registering Middleware) names a load balancer. prefers() picks the best match from your list, and expectsJson() decides whether errors render as JSON:
$ curl -s -H 'Authorization: Bearer tok_123' -H 'Accept: text/markdown,
application/json;q=0.9' \
"$B/echo/headers" | jq '{bearerToken, accepts, prefers, wantsMarkdown}' | kv
bearerToken = "tok_123"
accepts = ["text/markdown","application/json"]
prefers = "application/json"
wantsMarkdown = true
$ curl -s -H 'Sec-Fetch-Site: same-origin' -F 'cover=@cover.jpg;type=image/jpeg' \
$B/products/1/cover | kv
original = "cover.jpg"
client_mime = "image/jpeg"
mime = "image/png"
extension = "png"
bytes = 1206
stored_as = "covers/fnAnmSaLPcTfRz2qKCWjlAGZhMDbo0dzKLnDkS9l.png"The client ranked Markdown first, but the list offered only HTML and JSON. The product page offers all three, and wantsMarkdown() exists for agents that ask for Markdown:
return match ($request->prefers(['text/html', 'application/json', 'text/markdown'])) {
'application/json' => [...$product->toArray(), 'price_label' => $price],
'text/markdown' => response("# {$product->name}\n\nPrice: {$price}\n")
->header('Content-Type', 'text/markdown; charset=UTF-8'),
default => view('products.show', compact('product', 'price')),
};The upload was a PNG named cover.jpg and labeled image/jpeg. After hasFile() and isValid(), store('covers') used extension(), which reads the bytes, so the file got a random name ending in .png. Client names and types are claims: validate with mimes: (The Available Validation Rules).