You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add request/response/headers API documentation and E2E tests
- Add Request Object section with method, url, headers properties
- Add Response Object section with status, statusText, headers, ok properties
- Add Headers API section with get/has/set/append/delete/keys/values/entries/forEach
- Add comprehensive E2E tests for all request/response/headers methods
- Update transform variable lists to include request/response
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@@ -590,3 +597,101 @@ accepts: [json, form] # Both (default)
590
597
591
598
> [!WARNING]
592
599
> Returns 415 Unsupported Media Type if the request Content-Type doesn't match.
600
+
601
+
## Request Object
602
+
603
+
The `request` free variable provides read-only access to HTTP request information. Available in [pre](#pre-transform), [post](#post-transform), and [mock JS](#mock-js-variables).
> Setting `response.status` changes the HTTP status code of the response. This is different from throwing an error with `status` — the response body is still the return value of post-transform.
652
+
653
+
> [!WARNING]
654
+
> `response` is only available in post-transform. Accessing it in pre-transform or mock JS will result in `undefined`.
655
+
656
+
## Headers API
657
+
658
+
The Headers API follows the [Web API Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) interface.
659
+
660
+
| Method | Description |
661
+
|--------|-------------|
662
+
| `get(name)` | Get header value (`null` if not found) |
663
+
| `has(name)` | Check if header exists |
664
+
| `set(name, value)` | Set header value (replaces existing) |
665
+
| `append(name, value)` | Add header value (allows multiple) |
666
+
| `delete(name)` | Remove header |
667
+
| `keys()` | Get all header names |
668
+
| `values()` | Get all header values |
669
+
| `entries()` | Get `[name, value]` pairs |
670
+
| `forEach(callback)` | Iterate with `callback(value, name)` |
671
+
672
+
> [!NOTE]
673
+
> Header names are case-insensitive. `headers.get('Content-Type')` and `headers.get('content-type')` return the same value.
674
+
675
+
> [!IMPORTANT]
676
+
> `request.headers` is read-only — `set()`, `append()`, and `delete()` are silently ignored.
677
+
> `response.headers` is writable — all methods work as expected.
0 commit comments