What is MIME type "message/http"?
A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.
message/http encapsulates complete HTTP messages. It wraps the start line, headers, and an optional body. This structure preserves the original layout of an HTTP request or response.
It is used when HTTP data must travel outside normal web channels. The MIME container keeps the message intact for later processing.
- HTTP Transaction Debugging: Tools log and analyze full HTTP exchanges.
- HTTP Tunneling: Transports HTTP messages over other protocols.
- Proxy Communication: Proxies and intermediaries relay encapsulated HTTP data.
This MIME type ensures that every part of an HTTP message is maintained. It is useful in systems that require detailed record-keeping of HTTP interactions. For more technical details, check the IANA registration for message/http.
Associated file extensions
Usage Examples
HTTP Header
When serving content with this MIME type, set the Content-Type header:
Content-Type: message/http
HTML
In HTML, you can specify the MIME type in various elements:
<a href="file.dat" type="message/http">Download file</a>
Server-side (Node.js)
Setting the Content-Type header in Node.js:
const http = require('http');
http.createServer((req, res) => {
res.setHeader('Content-Type', 'message/http');
res.end('Content here');
}).listen(3000);
Associated file extensions
FAQs
What is the primary purpose of the message/http MIME type?
The message/http type is used to encapsulate an entire HTTP message, including the start line, headers, and body. It is most frequently seen when a web server responds to a TRACE request by echoing back the exact request it received for debugging purposes.
How do I open a file with the .http extension?
Since message/http content is fundamentally text-based, you can view it in any standard text editor like Notepad or Vim. Web developers often use the REST Client extension for VS Code to view and execute the HTTP requests defined in these files.
Why is message/http associated with security risks?
This MIME type is central to Cross-Site Tracing (XST) vulnerabilities. If a server enables the TRACE method, it returns the request as message/http; if malicious JavaScript intercepts this response, it may expose sensitive headers like HttpOnly cookies.
Can web browsers render message/http files?
No, standard web browsers like Chrome or Firefox do not render raw HTTP messages as formatted web pages. If a server delivers a file with this MIME type, the browser will typically force a file download or display the raw text content.
How do I configure Apache to serve .http files correctly?
To ensure your Apache server sends the correct Content-Type header, add the directive AddType message/http .http to your .htaccess file or main configuration. This prevents the server from defaulting to text/plain.
What is the structure of a message/http document?
A valid message/http entity starts with an HTTP status line (e.g., GET /index.html HTTP/1.1), followed by header fields, an empty line, and finally the message body. This structure strictly follows the format defined in RFC 7230.
General FAQ
What is a MIME type?
A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.
MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.
MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.
How do I find the MIME type for a file?
You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.
Why are multiple MIME types listed for one extension?
Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.