.http file format for defining HTTP requests. This page covers the complete syntax for request lines, headers, and bodies.
Request Line
The request line is the first line of each request block and follows this format:Components
- HTTP Method (required) - Standard HTTP methods:
GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS - URL (required) - Complete URL including protocol (http:// or https://)
- HTTP Version (optional) - Defaults to
HTTP/1.1if not specified
Supported HTTP Versions
HTTP/1.0HTTP/1.1(default)HTTP/2HTTP/3
Headers
Headers are specified asKey: Value pairs on separate lines following the request line. Each header must be on its own line.
Request with Headers
Header names are case-insensitive per HTTP specification, but HTTPSpec preserves the casing you provide.
Common Headers
Content-Type
Content-Type
Specifies the media type of the request body:
Authorization
Authorization
Accept
Accept
Indicates expected response format:
Request Body
The request body starts after a blank line following the headers. Everything between the blank line and the assertions (or next request) is treated as the body.JSON Body
POST with JSON
Plain Text Body
POST with Text
Multiline Body
Bodies can span multiple lines. HTTPSpec preserves line breaks in the body content:Multiline JSON
Request Names
You can name your requests using a comment line starting with###. This makes test output more readable and helps organize your test files.
Named Requests
Multiple Requests in One File
You can include multiple request blocks in a single file. Requests are separated by blank lines or request names and executed sequentially.Sequential Requests
Comments
Lines starting with# or // (but not //#) are treated as comments and ignored by the parser:
With Comments
The
//# prefix is reserved for assertions and is not treated as a regular comment.Real-World Example
Here’s a complete example from the HTTPSpec test suite:test.httpspec
Next Steps
Assertions
Learn how to validate responses with assertions
Variables
Use variables for dynamic request values