Skip to content

feat(http): add http.query() convenience method for the HTTP QUERY method - #6481

Open
ashrafiucse wants to merge 1 commit into
grafana:masterfrom
ashrafiucse:add-http-query-method
Open

ashrafiucse wants to merge 1 commit into
grafana:masterfrom
ashrafiucse:add-http-query-method

Conversation

@ashrafiucse

Copy link
Copy Markdown
Contributor

What?

Adds an http.query(url, body, params) convenience method for the HTTP QUERY method, as suggested in #6128.

QUERY (RFC 10008, Proposed Standard as of June 2026) is a safe, idempotent method that carries a request body — for queries too large, complex, or sensitive to put in the URL.

Why?

http.request('QUERY', url, body) already works since the method string passes through to net/http, but every other method has a discoverable helper (http.get, http.post, http.put, http.patch, http.del, http.options). This gives QUERY the same treatment.

Implementation

  • One-line export in js/modules/k6/http/http.go, mirroring the other body-carrying method helpers. net/http has no MethodQuery constant, so it's defined locally.
  • Regression test in TestRequest covering method, body, and headers round-trip through /anything.

Testing

  • go test -race ./js/modules/k6/http/ passes, including the new TestRequest/QUERY subtest.

Docs for the new method will need a follow-up in the docs repo.

Fixes #6128

@ashrafiucse
ashrafiucse requested a review from a team as a code owner September 21, 2026 20:23
@ashrafiucse
ashrafiucse requested review from AgnesToulet and janHildebrandt98 and removed request for a team September 21, 2026 20:23
@github-actions

github-actions Bot commented Sep 21, 2026

Copy link
Copy Markdown

Signed commits report

All 1 commit between master and add-http-query-method have verified signatures. ✅

…thod

RFC 10008 standardized the HTTP QUERY method: a safe, idempotent method
that carries a request body, for cases where the query is too large,
complex, or sensitive to put in the URL.

k6 could already issue QUERY requests through http.request('QUERY', ...),
since the method string is passed through to net/http. This adds the
http.query(url, body, params) helper for parity with the existing
per-method wrappers (get/post/put/patch/del/options), so QUERY is
discoverable and consistent now that it's a real standard.

Fixes grafana#6128

This branch has not been deployed

No deployments
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.

Add http.query() convenience method for the HTTP QUERY method (RFC 10008)

1 participant