Skip to content

Add HTTP QUERY method support (RFC 10008) - #5

Merged
JakeChampion merged 2 commits into
10.2.xfrom
claude/http-query-method-support-5v716q
Aug 24, 2026
Merged

JakeChampion merged 2 commits into
10.2.xfrom
claude/http-query-method-support-5v716q

Conversation

@JakeChampion

@JakeChampion JakeChampion commented Aug 22, 2026 •

Copy link
Copy Markdown
Owner

Draft. Adds support for the HTTP QUERY method (RFC 10008, Standards Track, June 2026).

This was the last of a four-PR stack. #6, #7 and #8 are now merged into 10.2.x, so this is rebased onto it and the diff is the QUERY work alone.

QUERY is a safe, idempotent method that carries request content. The load-bearing requirement is §2.7: the cache key MUST incorporate the request content and its related metadata. That means the content has to be read and digested before the cache lookup, which is the only structurally interesting part of this change — the rest is table work.

What is here

Method registration. QUERY is a well-known method, classified safe and idempotent. Exposed as TS_HTTP_METHOD_QUERY / TS_HTTP_LEN_QUERY, atscppapi::HTTP_METHOD_QUERY and cripts::Method::QUERY, counted by proxy.process.http.query_requests, usable in ip_allow.yaml methods: lists and @method= remap filters, and advertised in Allow.

Caching, opt-in via proxy.config.http.cache.query_method, mirroring cache.post_method. RFC 10008 makes reuse a MAY rather than a SHOULD, and enabling it makes every QUERY buffer its content.

The cache key. The buffered content is digested with the method and the Content-Type, Content-Encoding and Content-Language values, then folded into the URL-derived key. Three deliberate decisions:

  • Length-prefixed values, count-prefixed fields. Without the length prefixes, content "ab" with type "c" collides with content "a" and type "bc". Without the counts, an absent field is indistinguishable from a present-but-empty one, and only the first value of a repeated field would count.
  • SHA-256, not CryptoContext, which is MD5 outside FIPS builds. Every byte of this digest is request-supplied and MD5 collisions are constructible, so two chosen bodies could be made to share a cache entry. (Deliberately not SHA256Context::finalize(CryptoHash &), which writes 32 bytes into a union that is only 16 outside a FIPS build.)
  • Byte-exact, no normalization. §2.7 permits normalizing first; §4 warns that a normalization false positive returns the wrong stored response. A missed hit is preferred to a wrong hit.

Bypass rather than truncate. A QUERY bypasses the cache entirely — counted, never truncated — when its content is chunked, absent, or larger than the buffering limit. That limit is the lesser of cache.query_max_body_size and post_copy_size; ATS warns at startup if they disagree. Because HTTP/2 and HTTP/3 clients commonly omit content-length, QUERY caching in practice applies to requests arriving with an explicit Content-Length. All documented.

HTTP/2. QUERY joins content_method, so a QUERY carrying content is not sent with a premature END_STREAM.

303 redirect handling

RFC 9110 §15.4.4 says a 303 is followed with a GET carrying no content; ATS replayed the original method and content for every redirect status alike.

  • QUERY is converted unconditionally — RFC 10008 §2.5 requires it, and nothing can depend on prior behaviour for a method this version introduces.
  • Other methods are governed by the new overridable proxy.config.http.redirect.see_other_as_get, defaulting to conformant. Redirect following is itself off by default, so the deployments affected are those that enabled it and rely on the method being replayed.

Worth knowing: replaying request content across a redirect does not currently work at all — the followed request goes out with the original Content-Length and no body behind it. That predates this change and is untouched here; the test for the setting-off case therefore uses a POST with no content, and says so.

The one thing worth reviewing closely

QUERY is appended after PUSH in the well-known string table rather than inserted in the natural place. Method indices are persisted verbatim in cached request headers and never recomputed, so inserting would silently misinterpret the method of every already-cached object. Appending keeps every existing index fixed; a unit test pins each offset so a future alphabetical insert fails loudly.

The header tokens after the method block do shift, and those indices are persisted too — hence CACHE_DB_MINOR_VERSION 2 → 3, which makes older objects run through recompute_accelerators_and_presence_bits() on read. That bump is only safe because of the compatibility fixes in #8 (now merged), which pinned the HTTPInfo compat check to the version it actually describes and fixed the compressed-RAM-cache path that skipped the recompute.

No cache clear is needed. Rolling back to a stock 10.2.x binary will treat objects written by this one as corrupt, since it rejects future versions.

Tests

Unit tests for method registration (including index-stability and contiguity invariants), the classification predicates, and the digest — checking every adjacent field pair for the concatenation ambiguity the length prefixes prevent, and that content shorter or longer than its declared Content-Length is never keyed.

AuTests for caching enabled and disabled, content-varied and Content-Type-varied keys producing distinct entries, both directions of cross-method contamination, the oversize bypass, ip_allow/remap ACL filters, and the three 303 cases. The content-in-the-key tests were mutation-tested: with apply_query_cache_key() disabled they fail, so they are not passing vacuously.

Defects found and fixed during review

Two review passes over the diff turned up more than the feature work did:

  1. The feature was inert. is_this_http_method_supported() did not know QUERY, so check_request_validity() forced tunnelling mode and cache.query_method had no effect whatsoever.
  2. MD5 cache keys over entirely attacker-supplied bytes (above).
  3. Digest collisions on repeated and absent-vs-empty metadata fields.
  4. Retry with an unreplayable body. Marking QUERY safe removed the retry bail-out protecting content-carrying methods, so ATS could retry a QUERY whose content had already been consumed. Retry is now conditional on the content still being replayable — which is not the same as the post buffer merely existing, since that is also allocated when redirect following is enabled.
  5. A 403 instead of a cache bypass: the buffering decision ignored post_copy_size (default 2048), so with caching on, any QUERY body over 2 KB failed the transaction as 403 Access Denied.
  6. A redirect re-buffered the content and stalled waiting for content the client had already sent.
  7. Expect: 100-continue deadlocked a buffered QUERY: the client waits for a 100 only the origin can send, and the origin is not contacted until the content is read.
  8. The truncation guard could not fire — the reader skips empty blocks, so it always yielded exactly read_avail(). Replaced with a real cross-check against Content-Length.
  9. A use-after-free in the 303 handling, caught by its own test on first run: client_response does not survive the redirect rewrite, so the status must be read before it, not after.

Known limitations, documented

  • A stored QUERY response cannot be purged or invalidated by URL, since it is keyed partly on its content. RFC 10008 defines no mechanism for addressing these entries.
  • Request Content-Location is not digested. Missed hits only, never a wrong hit.

@JakeChampion
JakeChampion force-pushed the claude/http-query-method-support-5v716q branch from bf2dfd0 to c2937ea Compare August 22, 2026 08:37
@JakeChampion
JakeChampion changed the base branch from 10.2.x to claude/cache-compat-fixes August 22, 2026 08:37
@JakeChampion
JakeChampion force-pushed the claude/cache-compat-fixes branch from 14cb4b8 to 9e54faa Compare August 22, 2026 09:30
@JakeChampion
JakeChampion force-pushed the claude/http-query-method-support-5v716q branch from c2937ea to 9e146eb Compare August 22, 2026 09:30
QUERY is a safe, idempotent method that carries request content, and its
cache key must incorporate that content. Register it as a well known
method and classify it as safe and idempotent so retry, invalidation and
connection reuse treat it correctly. Expose it through the plugin API,
the C++ API and Cripts, count it, and accept it in ip_allow.yaml method
lists and @method= remap filters.

Caching is opt-in via proxy.config.http.cache.query_method. When enabled
the request content is buffered before the cache lookup and digested,
with the method and the Content-Type, Content-Encoding and
Content-Language values, into the cache key. Fields are length and count
prefixed so distinct requests cannot produce the same digest. Values are
digested byte for byte rather than normalized: RFC 10008 permits
normalizing but warns that a false positive returns the wrong stored
response, so a missed hit is preferred to a wrong hit. SHA-256 is used
rather than CryptoContext, which is MD5 outside a FIPS build: every byte
of this digest is supplied by the request, and constructing an MD5
collision is cheap.

A QUERY whose content is chunked, absent, larger than
proxy.config.http.cache.query_max_body_size, or larger than
post_copy_size, bypasses the cache and is counted, rather than being
keyed on part of its content, which would let two distinct queries
collide.

QUERY is appended after PUSH in the well known string table so that the
indices of the existing methods, which are persisted in cached request
headers, do not move. The header tokens after it do shift, so the cache
minor version is bumped to have those recomputed on read.

Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xp4ZMfVaT5EzvZsyMTx2y5
@JakeChampion
JakeChampion force-pushed the claude/http-query-method-support-5v716q branch from 9e146eb to f483171 Compare August 22, 2026 10:18
@JakeChampion
JakeChampion changed the base branch from claude/cache-compat-fixes to 10.2.x August 22, 2026 10:19
@JakeChampion
JakeChampion marked this pull request as ready for review August 23, 2026 14:52
@JakeChampion
JakeChampion merged commit 2d1a745 into 10.2.x Aug 24, 2026
8 checks passed
@JakeChampion
JakeChampion deleted the claude/http-query-method-support-5v716q branch August 24, 2026 16:07
ebremer added a commit to ebremer/RFC10008support that referenced this pull request Sep 4, 2026
The headline is Starlette. The ASGI layer under FastAPI merged QUERY at
+75 -- the maintainer landed his own branch the day he opened it and
closed both community PRs (+9 test client, +20 routing) in its favour.
FastAPI pins starlette>=0.46.0, so the ASGI half of that story is done,
and the discussion (+78) now puts the remaining gate on ReDoc 2
specifically rather than OpenAPI 3.2 generally: Swagger UI supports 3.2,
ReDoc is gated on 3.1 and would not classify query as an operation.

Django got a real PR. The contributor's fork became django/django#21855
at +74 and is drawing fellow review: QUERY content exposed through
HttpRequest.body and deliberately not parsed, the same treatment as PUT,
with the diff reaching admin, auth admin, the common/CSRF/conditional-GET
middleware, utils.cache, the HTTP view decorators and the test client.
The live question is scope -- whether cache/Vary support must land in the
same PR or a follow-up ticket.

Vapor is unblocked. swift-http-types 1.7.0 shipped at +79 with "Make
QUERY method public" (#130), which was the exact condition the approved
Vapor PR was held for. Nothing blocks it now; it simply has not been
touched since +73. SwiftNIO's own PR is the last unmerged piece of the
Swift stack.

Status changes: fasthttp merged (+73), reitit merged (+76) after 69 days
when a maintainer put it in mergeable shape himself, Hanami merged (+80).
Next.js is out of draft but still unreviewed. Helidon changed shape --
after months where Oracle's contributor agreement was the blocker (the
OCA download 404s outside the US), a maintainer said at +79 he will take
the work over as a PR of his own with the contributor as co-author.
Jakarta REST woke up after 62 days: a new contributor volunteered at +79
for the whole scope, annotation through TCK, though the underlying
committer vote has not changed. nghttp2 closed not planned at +77 -- the
stale bot, not a decision; nobody ever replied. oasdiff released in
v1.30.0 (+75). GoFr took a second full review round at +78 and is the
most actively reviewed open QUERY PR in the tracker.

Non-events worth recording: Envoy's merge still has no release (1.40 not
cut, latest v1.39.1 at +72), Spring has cut no milestone since M1 missed
the merge, Slim 4.15.3 shipped at +77 without the 4.x backport even
though the maintainer pushed the fix himself at +67, django-ninja 1.7.0
shipped at +75 without its PR, and Kong's discussion has now sat 46 days
with zero comments.

New rows (14). Servers: Grape (merged same-day at +78, the maintainer
"excited to beat Rack and Rails on QUERY support", and correct, since
Rails' merge is still unreleased), Wolverine, Tempest, APIFlask,
Comunica (merged +77 -- the SPARQL engine many Solid apps sit on, moving
before the protocol spec did), GenHTTP, Marko Run, Lilya. Clients: Kiota
(the maintainer scoped it to adding QUERY to each language's HttpMethod
enum, since arbitrary verbs would be source-breaking), Gleam http.
Tooling: httpYac, hono-openapi, sphinxcontrib-httpdomain, W3C SPARQL
Protocol (closed completed +77 -- not a first-class 1.2 binding, since
1.2 is scoped to RDF 1.2 and errata, but an informative Note mirroring
the existing HTTP PATCH note).

Also: Apache Traffic Server's row now names the fork carrying the work
(JakeChampion/trafficserver#5, merged +69), since nothing has been
proposed upstream; chi's row records that v5.3.1 was tagged the day after
the merge, the fastest request-to-release turnaround here; HTTP::Message
shipped in v7.04 the same day it merged; and Apache HttpClient's alpha1
date is corrected from +52 (the RC3 tag) to +58 (rel/v5.7-alpha1).

All 120 changed star counts refreshed as of 2026-09-04. Every tracked
issue and PR was re-checked against its live state, and release claims
were checked against tags and changelogs rather than inferred from merge
dates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants