Skip to content

feat: match httpbin.org on the open issues - #762

Merged
harryjackson merged 20 commits into
masterfrom
issues/match-httpbin-org
Nov 12, 2026
Merged

harryjackson merged 20 commits into
masterfrom
issues/match-httpbin-org

Conversation

@harryjackson

Copy link
Copy Markdown
Collaborator

One branch for the open issues, each matching httpbin.org.

Generated with Claude Code

harryjackson and others added 20 commits November 12, 2026 12:43
/image answered 406 to an Accept header with */* in it, even though */*
accepts any type, so curl-style clients got an error (#566). A */* range
that isn't refused (q above 0) now gets the PNG, the same as no Accept
header at all. The preference order is unchanged: webp, svg, jpeg, then
png or image/*. avif-only and text/html-only still get 406. This is
httpbin.org's behaviour.

Co-Authored-By: Claude <noreply@anthropic.com>
Clients that append a path to the base URL they were given, such as
/status/200/foo, got a 404 (#714). /status/{code}/{anything} now answers
like /status/{code}, for every method the route takes, as on httpbin.org.
A bad code is still a 400.

Co-Authored-By: Claude <noreply@anthropic.com>
/status/{code} answers with an empty body, so a client can't test how it
shows an error page (#627). With ?body=1 (or true), the response carries
the code's standard reason phrase: {"code": 500, "description":
"Internal Server Error"} when Accept prefers application/json, and
"500 Internal Server Error" as text/plain otherwise, with Vary: Accept.
The body is only ever the standard phrase, never anything the caller
sends. Without the flag nothing changes. Codes without a body (1xx, 204,
205, 304) and those with their own (402, 406, 418) are unchanged, and
redirect and auth headers are kept. This is httpbin.org's behaviour,
reason phrases included.

Co-Authored-By: Claude <noreply@anthropic.com>
A multipart form that repeats a file field, such as two files under
"f", came back with only the first one, and every file was labelled with
the first one's Content-Type (#682). The files echo now lists every file
of the field in order, each with its own type in the data URL when it is
binary. A single file is echoed as before. This matches httpbin.org.

Co-Authored-By: Claude <noreply@anthropic.com>
QUERY is a safe HTTP method that carries a body, and clients were
getting a 405 for it (#734). /anything, /anything/... and /delay/{n} now
accept QUERY and echo it like POST: args, form, files, data and json, and
"method": "QUERY" where the echo reports the method. Every other route
still answers 405. This matches httpbin.org.

Co-Authored-By: Claude <noreply@anthropic.com>
There was no way to see a request as the server received it: which
method was sent (#522), or the Content-Type of each part of a multipart
upload (#722). /dump/request returns the request in its HTTP/1.x form as
text/plain: the request line, Host, then the other headers sorted by
name, and the body. A chunked body is shown chunked. It answers every
method, including ones no other route accepts. It is approximate: the
WSGI server has already merged repeated headers and lost the original
order and case of the names. Under gunicorn its output is byte-for-byte
httpbin.org's for the same request.

Co-Authored-By: Claude <noreply@anthropic.com>
Taken from feat/auth-cookies-cache (a4634df); the digest challenge without qop
(public issue 592).

Co-Authored-By: Claude <noreply@anthropic.com>
attr[HttpOnly], attr[SameSite], attr[Path], attr[Secure] and attr[Domain], the
last only when it is the request host (public issue 508). Based on
feat/auth-cookies-cache (9840bae); error_response is added here because that
branch had it from the redirect-to work.

Co-Authored-By: Claude <noreply@anthropic.com>
…ocumented

- The basic, hidden basic, bearer and digest auth routes take GET, POST, PUT,
  DELETE, PATCH and TRACE, as httpbin.org does (public issue 508 context;
  supersedes PR 607).
- /zstd returns the request echo compressed with zstd, like /gzip and /brotli
  (public issue 736). It uses the standard library on Python 3.14 and the
  optional backports.zstd package before that, and says 501 without either.
- show_env is documented on the home page and in the spec (public issue 513),
  and the README says what httpbin is (public issue 691).

Co-Authored-By: Claude <noreply@anthropic.com>
Regenerated both hashed lock files with the zstd extra (uv 0.13.8, the commands in
their headers), so the tests exercise /zstd on 3.11 to 3.13. Nothing else
changed in the locks.

Co-Authored-By: Claude <noreply@anthropic.com>
# Conflicts:
#	httpbin/core.py
#	httpbin/helpers.py
#	test_httpbin.py
POSTing a form to /redirect-to gave a 500 (#593): the url was only read
from the query, and a missing one raised a KeyError. A non-numeric
status_code made int() raise too. url and status_code are now read from
a urlencoded or multipart form body as well (POST, PUT, PATCH, DELETE).
A name the query has, in any case, wins, and files are skipped. A missing
or empty url gets a 400 "missing required query parameter: url", and a
non-numeric status_code a 400 "invalid status code: ...", both as JSON.
The target checks and the allowlist apply to a form value as to a query
one. This matches httpbin.org.

Co-Authored-By: Claude <noreply@anthropic.com>
A /delay/{n} that wasn't a plain number, or was negative, raised in
float() or time.sleep() and gave a 500 (#746). n is now read as
httpbin.org reads it: a decimal or hex-float number of seconds, with
underscores allowed between digits. Anything else, an overflowing value
or a negative one gets a 400 JSON error "invalid duration: ...". The
10-second limit is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
Clients timing these endpoints can now see what the server was asked
to do: the initial delay, and for /drip the write duration and the
pause between bytes, in milliseconds. This was requested in #560.

/drip now spreads the bytes over the whole duration, pausing between
bytes rather than after each one, so the last byte arrives at the end
of the duration instead of one pause later. With no duration it writes
everything at once. Durations count in whole milliseconds, as on
httpbin.org.

Co-Authored-By: Claude <noreply@anthropic.com>
/drip always sent a Content-Length, so there was no way to test a
client against a slow chunked body (#479). With chunked=1 (or true)
the Content-Length is left off and the server sends the body with
Transfer-Encoding: chunked, as httpbin.org does.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
/json, /xml, /html, /robots.txt, /deny, /encoding/utf8 and /image (and its
type routes) answer with their normal body and Content-Type under the given
status, 200 to 599 where a body is allowed. 1xx, 204, 205 and 3xx, and
anything that is not one plain number, get a fixed plain-text 400 that does not
repeat the value. /response-headers takes status=N too: it is never sent as a
header, and Location and Refresh are refused with it, so the answer is never a
redirect. An unacceptable Accept on /image still answers 406 (public issue 612;
as go-httpbin does).

Co-Authored-By: Claude <noreply@anthropic.com>
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