Content-Type
BothActiveThe Content-Type header describes the media type and encoding of the message body. It tells the receiver how to parse the body – as JSON, HTML, form data, binary, etc. Including the charset parameter prevents encoding mismatches.
Content-Type: <media-type>[; charset=<charset>][; boundary=<boundary>]
Description
The Content-Type representation header is used to indicate the original media type of the resource before any content encoding applied for sending. In responses, it tells the client what the content type of the returned content actually is.
Directives
| Directive | Description |
|---|---|
| application/json | JSON-encoded data. Most common for REST APIs. |
| text/html; charset=utf-8 | HTML document, UTF-8 encoded. |
| application/x-www-form-urlencoded | HTML form submission (default form enctype). |
| multipart/form-data | File uploads and binary form data. |
| application/octet-stream | Arbitrary binary data / file download. |
Examples
JSON response
http
Content-Type: application/json; charset=utf-8HTML document
http
Content-Type: text/html; charset=utf-8Form submission
http
Content-Type: application/x-www-form-urlencoded