v0.1.2

.http File Format

Last updated


This page explains how the parser splits request blocks, recognizes request lines, and skips comments; see Headers and Body for how headers and bodies are detected.

Request Blocks


A standalone ### line ends the current request and adds it to the list; a ### Name line only sets the name shown in the left pane for the next request and does not end the current one. An unterminated request at end of file is still included.
  1. ### Create Post
  2. POST https://jsonplaceholder.typicode.com/posts
  3. Content-Type: application/json
  4. {
  5. "title": "Test Post",
  6. "userId": 1
  7. }
  8. ###

A request without a ### Name line shows an empty name in the left pane.

Request Line


A request line must match ^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s+(.+)$:
RuleDescription
MethodOnly the 7 methods above, uppercase only; get is not recognized
URLEverything after the method; a trailing HTTP/1.1 becomes part of the URL
PositionA request line starts a new request and resets header and body state; the previous request is added to the list only if it already has a body, otherwise it is discarded, so end every request with ###

Comments


Whether a line is skipped depends on whether the parser is inside a body:
LineOutside a bodyInside a body
Blank lineSkippedKept as body content
Starts with // or --SkippedKept as body content
Starts with # (but not ###)SkippedSkipped, never added to the body
### NameSets the next request's nameSets the next request's name, never added to the body
中文