Observe an HTTP QUERY request
Run a safe cross-origin QUERY request and inspect the final response shared with JavaScript.
- methods
- request content
- CORS
- preflight
Prediction
The browser should send OPTIONS before QUERY because QUERY is not a
CORS-safelisted method. The intended request should then carry JSON content even
though its semantics are safe and idempotent.
Controlled observation
Choose one of two reviewed query shapes. Both target the same fixed resource,
declare application/json, and return a small fixed dataset. The response’s
Accept-Query field advertises the accepted query media type. The result panel
shows the final QUERY response; use browser developer tools to inspect the
automatically generated OPTIONS exchange.
Explanation
QUERY places the query representation in request content while preserving safe
and idempotent semantics. Its Content-Type defines the query format;
Accept-Query advertises which formats the resource accepts. In a cross-origin
browser, preflight separately asks whether the page may send the QUERY method and
JSON content type.
Controlled exercise
Run this observation
Inspect the final QUERY response and Accept-Query field; inspect developer tools to see OPTIONS separately.
Interactive controls require JavaScript. The static response and portable examples remain available below.
Ready. No request has run.
Controlled request
- Method
- QUERY
- URL
https://lab.httpclarity.com/v1/query- Permitted headers
- Accept: application/json; Content-Type: application/json
- Body
- 29 bytes (fixed): {"status":"active","limit":2}
Browser-observed response
No live response yet. The representative static example remains useful without JavaScript or the Worker.
Static response example
HTTP/1.1 200 OK
Accept-Query: "application/json"
Cache-Control: private, max-age=30
{"query":{"limit":2,"status":"active"},"results":[{"id":101,"name":"Ada","status":"active"},{"id":103,"name":"Sam","status":"active"}],"scenario":"query-method"}Timing is browser elapsed time. Fetch hides Set-Cookie, raw wire bytes, reliable compressed size, and some redirect details.
Portable examples
'curl' '--include' '--request' 'QUERY' '--header' 'Accept: application/json' '--header' 'Content-Type: application/json' '--data' '{"status":"active","limit":2}' 'https://lab.httpclarity.com/v1/query'Scroll horizontally to read any long lines.const response = await fetch("https://lab.httpclarity.com/v1/query", {
"method": "QUERY",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json"
},
"body": "{\"status\":\"active\",\"limit\":2}"
});
console.log(response.status, await response.text());Scroll horizontally to read any long lines.<?php
$options = ['http' => [
'method' => 'QUERY',
'ignore_errors' => true,
'header' => 'Accept: application/json\\r\\nContent-Type: application/json',
'content' => '{"status":"active","limit":2}',
]];
$context = stream_context_create($options);
$body = file_get_contents('https://lab.httpclarity.com/v1/query', false, $context);
var_dump($http_response_header, $body);Scroll horizontally to read any long lines.Need a full API client? Copy the generated cURL command, then import it in Hoppscotch. HTTPClarity sends no request data to Hoppscotch.
Continue in Hoppscotch (opens in a new tab)