Skip to content

Add the HTTP QUERY method (RFC 10008) - #1059

Open
mbeijen wants to merge 5 commits into
apache:trunkfrom
mbeijen:rfc10008-query
Open

mbeijen wants to merge 5 commits into
apache:trunkfrom
mbeijen:rfc10008-query

Conversation

@mbeijen

@mbeijen mbeijen commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds QUERY as a built-in method (M_QUERY), following RFC 10008. A QUERY without Content-Type gets 400 unless HttpProtocolOptions Unsafe is set, and conditional QUERY requests are evaluated like GET (weak ETag comparison, 304 instead of 412).

mod_dir, mod_cgi, mod_cgid, mod_lua, mod_charset_lite and mod_reflector treat QUERY content like POST content.

  • M_QUERY takes number 26 and moves M_INVALID to 27, hence the major MMN bump.
  • If a backport to 2.4.x is wanted, M_QUERY could be 27 instead, with M_INVALID left at 26 and the range for runtime-registered methods starting at 28; that needs no major bump. Happy to switch.
  • mod_proxy_ajp now uses ap_method_is_idempotent(), which also makes PROPFIND and REPORT retryable after a backend failure.
  • Left out on purpose: the Accept-Query response header (it can be set with mod_headers) and caching of QUERY responses in mod_cache, which will follow as a separate PR.

I used AI assistance creating these PRs. I have a separate follow-up PR for handling caching in mod_cache

  • This PR does not report or address a security vulnerability (see SECURITY.md and https://www.apache.org/security/#reporting-a-vulnerability).
  • Code follows the httpd style guide.
  • New log messages (level debug or higher) use an empty APLOGNO() tag; numbers are assigned by a committer at merge time (see docs/log-message-tags/README).
  • If the change is user-visible, a changes-entries/*.txt file is included, following the template in README.CHANGES (not needed otherwise).
  • Test cases based on pyhttpd are included where appropriate, in the test/modules/xxx directory matching the modules/xxx module source, or test/modules/core for core server changes. On Unix, verify these pass locally with e.g. make check-pytest PYTEST_DIRS=test/modules/xxx.

@mbeijen
mbeijen marked this pull request as ready for review November 19, 2026 21:21
Register QUERY as built-in method M_QUERY (26), which moves M_INVALID
to 27 and therefore needs a major MMN bump.  Add ap_method_is_safe()
and ap_method_is_idempotent() for code that has to decide whether a
request can be retried or served like GET.

Implement the server-side rules of RFC 10008 that apply to every
resource:

* A QUERY request without Content-Type fails with 400 (Section 2),
  except for forward proxy requests and with
  "HttpProtocolOptions Unsafe".
* Conditional QUERY requests are evaluated like GET (Section 2.6):
  weak ETag comparison, and 304 instead of 412 for If-None-Match and
  If-Modified-Since, also for CGI responses.

mod_proxy_ajp gets a placeholder entry for M_QUERY in its method table
so that indexing by method number stays within bounds.
QUERY (RFC 10008) carries request content, so the modules that pass
POST bodies on to applications have to treat it the same way:

* mod_dir: resolve DirectoryIndex for QUERY, so that QUERY on "/"
  reaches e.g. index.php.
* mod_cgi, mod_cgid: write QUERY bodies to the ScriptLog.
* mod_lua: r:requestbody() returns QUERY bodies.
* mod_charset_lite: translate QUERY bodies.
* mod_reflector: reflect QUERY bodies, and announce QUERY in Allow.

mod_negotiation and mod_actions need no change: MultiViews already
prefers scripts for non-GET methods, and "Script QUERY ..." works
through the method registry.

Add tests for the ScriptLog of mod_cgid, mod_charset_lite and mod_lua to
the generators, filters and lua suites; DirectoryIndex and
mod_reflector are tested with the HTTP/1 QUERY tests.
QUERY is idempotent (RFC 10008, Section 2), so mod_proxy_ajp may resend
a QUERY without request content after a backend failure, as it does for
GET.  It now asks ap_method_is_idempotent() instead of keeping its own
list of methods, which makes PROPFIND and REPORT idempotent as well.
AJP13 has no method code for QUERY; it goes out as SC_M_JK_STORED with
an SC_A_STORED_METHOD attribute, like PATCH.

mod_proxy_http needs no change: it forwards the method and content
whatever the method, and only retries when its 100-continue ping fails.
Add tests that QUERY, its Content-Type and its content reach HTTP and
AJP backends.
mod_http2 and mod_proxy_http2 pass any method and its content through,
so QUERY (RFC 10008) needs no change there.  Test that QUERY content
reaches a CGI over HTTP/2 directly, via mod_proxy_http and via
mod_proxy_http2, and that a QUERY without Content-Type gets a 400.
Mention QUERY (RFC 10008) in the <Limit> method list, describe how
HttpProtocolOptions treats a QUERY without Content-Type, and add the
user and developer visible changes to the 2.6 new features page.
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.

1 participant