{
  "flavors": {
    "ok": "The control, fully correct: Accept-Ranges, strong ETag, Last-Modified; single, suffix, open-ended and multiple ranges (multipart/byteranges), 416 with \"bytes */length\" when unsatisfiable, If-Range honored (strong validators only), and the conditional headers evaluated as RFC 9110 says. HEAD ignores Range, as the spec requires. No Range gets a 200.",
    "ignore": "No range support at all: no Accept-Ranges header, and every request gets a 200 with the full body. Legal — range support is optional — and the #1 real-world case: a resuming client must notice the 200 and start over, not append.",
    "advertise-only": "Advertises Accept-Ranges: bytes on every response, then ignores every Range header and sends 200 with the full body. Aimed at segmented downloaders (aria2 and friends) that split into N connections because of the advertisement — and then receive N full bodies.",
    "off-by-one": "Treats the range end as exclusive: bytes=a-b gets bytes a..b-1, one short, while Content-Range still claims a-b. Content-Length matches the short body, so the two headers disagree — the classic fencepost, one missing byte per segment. The lie is applied to the first range; extra ranges are ignored.",
    "shifted": "Serves bytes a+1..b+1 while Content-Range claims a-b. The envelope looks right; every byte is wrong — detectable only because the body is self-describing (the offsets inside the file will not match where you put them). At the end of the document the shifted window is clamped, so the final segment also runs one byte short. First range only.",
    "suffix-as-prefix": "The naive suffix-range bug: bytes=-n is served as the FIRST n bytes of the document while Content-Range claims the last n. A client resuming \"the tail\" appends the head — silent corruption on exactly the request curl sends for a suffix. The lie applies when the first range is a suffix; any other request is served correctly, multipart included.",
    "from-zero": "Acknowledges your range with a 206 — then serves the whole document from byte zero, with an honest Content-Range: bytes 0-{length-1}/{length} that simply disagrees with what you asked. A client that appends without checking Content-Range against its request builds a file with a duplicated prefix.",
    "wrong-total": "Correct bytes, but Content-Range lies about the total: bytes a-b/{2×length}. Asking for bytes past the real end gets 416 with the same inflated total, so a download loop that trusts it never finishes. First range only.",
    "no-content-range": "A single-range 206 with the right bytes and no Content-Range header (a violation of RFC 9110 §15.3.7). What offset does your client think this is? First range only.",
    "always-206": "A request with no Range header still gets a 206 (Content-Range: bytes 0-{length-1}/{length}, full body). With a valid Range it behaves correctly; an ignored Range (malformed, or over the caps) is treated as absent, so it also gets the full-body 206. Some CDNs and proxies really do this.",
    "200-content-range": "Honors the range — right bytes, right Content-Range header — but the status is 200. A contradiction: which does your client believe, the status or the header? First range only.",
    "always-416": "Every Range request gets 416 with Content-Range: bytes */{length}; without Range, a 200. Tests give-up-and-restart logic.",
    "unknown-total": "Correct 206, but Content-Range says bytes a-b/* — total unknown, which is legal. Preallocation and progress logic that requires the total breaks. First range only.",
    "if-range-ignored": "The resource changes on every request (a generation stamp appears in the ETag and in every line of the body) and If-Range is ignored: a stale validator still gets a 206 from the new generation, where a correct server would send the full 200. Resume across it and your file mixes generations — run grep -oE \"g[0-9a-f]{16}\" file | sort -u on it: more than one value is the corruption. Nondeterministic by design."
  },
  "usage": "/range/{flavor}?length=1000",
  "document": "Deterministic and self-describing: 64-byte lines, each \"{offset:08d} {length:08d} badhttp range body {gen}\" padded with dots to 63 characters plus a newline; line 0 at length=1000 is \"00000000 00001000 badhttp range body g1\" + 24 dots. The final line is cut at ?length= (default 1000, max 1048576), so the document may end mid-line. The generation is g1 everywhere except if-range-ignored.",
  "limits": {
    "max_bytes": 1048576,
    "max_ranges_per_request": 8,
    "note": "more ranges than the cap, a total span over max_bytes, or any invalid range spec makes the whole Range header ignored — treated as if no Range was sent (a 200 with the full body at every flavor except always-206, which then sends its full-body 206, and always-416, which answers any Range header, even an ignorable one, with its 416)"
  },
  "conditionals": "ok evaluates If-Match / If-Unmodified-Since / If-None-Match / If-Modified-Since correctly and honors If-Range; the misbehaving flavors ignore conditionals entirely (their subject is ranges — /etag is the conditional-request family). HEAD ignores Range on every flavor, as RFC 9110 §14.2 requires.",
  "multipart": "Several satisfiable ranges come back as multipart/byteranges (boundary \"badhttp\"), served in request order without coalescing; when only one of several survives clamping it is served as a plain single-range 206. Responses are cache-control: no-store, no-transform — this family tests clients, not caches; point caches at /etag.",
  "witness": {
    "measured": "2026-10-12T05:39:32.005Z",
    "observations": 150,
    "control_rows": 16,
    "data": "https://badhttp.dev/clients.jsonl",
    "data_note": "Every observation is a row of /clients.jsonl with family \"range\", joined to /corpus.jsonl by corpus_id; /clients indexes them with the class legend, the outcome, shape and transfer legends and the per-flavor disagreement. The findings below are a reading of those rows, not a second source.",
    "what_this_is": "10 real resuming download clients plus a raw-wire control (curl), one fresh working directory per cell. Each cell holds the first 400 bytes of the 1000-byte document and tells the client to resume it from GET /range/{flavor}; the harness never sends a Range header itself. One extra cell per client downloads from nothing at always-206. It is a DATED CAPTURE, not a live measurement. Every request the client sent went through a local recording reverse proxy that forwarded it to this service over TLS and returned the response verbatim, so each row lists the exchanges the client actually made. The reference for each flavor is where RFC 9110 places the bytes the control received (a 200 replaces the file, a 206 puts its body at the offset its Content-Range names, a 206 without one and some 416s place nothing), checked against the true document the control also fetched whole; each row says whether it matches the reference placement. An outcome describes the file and the exit; RFC 9110 defines what a 206 means and no resume algorithm, so a client that starts over on a 200 and one that stops with an error are both doing something the specification allows. No client here is scored or ranked. Re-run it and move the date rather than letting it stale.",
    "clients": [
      "curl curl 8.7.1 (x86_64-apple-darwin26.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.69.0 (resumer)",
      "go-getter v1.8.10 (resumer)",
      "grab v3.0.1 (resumer)",
      "HTTPie 3.2.4 (resumer)",
      "huggingface_hub 2.2.0 (resumer)",
      "node-downloader-helper 2.1.11 (resumer)",
      "nugget 2.2.0 (resumer)",
      "GNU Wget GNU Wget 1.25.0 built on darwin27.0.0. (resumer)",
      "GNU Wget2 GNU Wget2 2.3.0 - multithreaded metalink/file/website downloader (resumer)",
      "yt-dlp 2026.08.19 (resumer)"
    ],
    "control": [
      "curl curl 8.7.1 (x86_64-apple-darwin26.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.69.0"
    ],
    "reference": "REFERENCE in the /clients range family block: per flavor, the status, Content-Range, Content-Length and body size the control received for Range: bytes=400-, where RFC 9110 places those bytes, and whether that placement applied to the partial yields the document",
    "findings": [
      "10 resuming download clients (curl, go-getter, grab, HTTPie, huggingface_hub, node-downloader-helper, nugget, GNU Wget, GNU Wget2, yt-dlp) were each given a 400-byte partial of the 1,000-byte document and told to resume it from /range/{flavor} — 14 flavors, plus one fresh download at always-206 — 150 rows in all. By the file and the exit: 84 complete, 42 corrupt, 17 refused, 3 unchanged, 2 incomplete-reported, 2 harness-timeout. Of the 42 corrupt rows, 19 wrote what the reference placement (where RFC 9110 puts the bytes the control received) itself yields and 22 differ from it.",
      "ok (the control got 206 with Content-Range bytes 400-999/1000 and 600 body bytes; reference placement: bytes 400-999, which yields the document): all 10 clients finished the file by keeping the partial.",
      "ignore (the control got 200 with no Content-Range and 1000 body bytes; reference placement: whole representation, which yields the document): go-getter, grab, HTTPie, huggingface_hub, node-downloader-helper, GNU Wget, yt-dlp finished the file by starting over after one response; nugget, GNU Wget2 wrote a file that is not the document (shape duplicated-prefix); curl stopped with an error and left the partial untouched.",
      "advertise-only (the control got 200 with no Content-Range and 1000 body bytes; reference placement: whole representation, which yields the document): HTTPie, huggingface_hub, node-downloader-helper, GNU Wget, yt-dlp finished the file by starting over after one response; go-getter, grab, nugget, GNU Wget2 wrote a file that is not the document (shape duplicated-prefix); curl stopped with an error and left the partial untouched.",
      "off-by-one (the control got 206 with Content-Range bytes 400-999/1000 and 599 body bytes; reference placement: bytes 400-999, which does not yield the document): curl, go-getter, grab, node-downloader-helper, nugget, GNU Wget2, yt-dlp wrote a file that is not the document (shape short); HTTPie, huggingface_hub stopped with an error after a prefix of the document; GNU Wget was still going when the 30 s cap fired.",
      "shifted (the control got 206 with Content-Range bytes 400-999/1000 and 599 body bytes; reference placement: bytes 400-999, which does not yield the document): curl, go-getter, grab, HTTPie, huggingface_hub, node-downloader-helper, nugget, GNU Wget2, yt-dlp wrote a file that is not the document (shape shifted); GNU Wget was still going when the 30 s cap fired.",
      "suffix-as-prefix (the control got 206 with Content-Range bytes 400-999/1000 and 600 body bytes; reference placement: bytes 400-999, which yields the document): all 10 clients finished the file by keeping the partial.",
      "from-zero (the control got 206 with Content-Range bytes 0-999/1000 and 1000 body bytes; reference placement: bytes 0-999, which yields the document): go-getter, grab, huggingface_hub, node-downloader-helper, nugget, GNU Wget2 wrote a file that is not the document (shape duplicated-prefix); curl, HTTPie, GNU Wget stopped with an error and left the partial untouched; yt-dlp finished the file by starting over after one response.",
      "wrong-total (the control got 206 with Content-Range bytes 400-999/2000 and 600 body bytes; reference placement: bytes 400-999, which yields the document): curl, go-getter, grab, huggingface_hub, node-downloader-helper, nugget, GNU Wget, GNU Wget2, yt-dlp finished the file by keeping the partial; HTTPie stopped with an error and left the partial untouched.",
      "no-content-range (the control got 206 with no Content-Range and 600 body bytes; reference placement: none (a 206 without Content-Range says nothing about where its body belongs)): go-getter, grab, huggingface_hub, node-downloader-helper, nugget, GNU Wget2 finished the file by keeping the partial; curl, HTTPie, GNU Wget stopped with an error and left the partial untouched; yt-dlp discarded the partial and kept the response body alone as the file (600 bytes).",
      "always-206 (the control got 206 with Content-Range bytes 400-999/1000 and 600 body bytes; reference placement: bytes 400-999, which yields the document): curl, HTTPie, huggingface_hub, node-downloader-helper, nugget, GNU Wget, GNU Wget2, yt-dlp finished the file by keeping the partial; go-getter, grab finished the file by starting over after one response.",
      "always-206, fresh (no partial, so no Range is sent; the control got 206 with Content-Range bytes 0-999/1000 and 1000 body bytes): all 10 clients wrote the whole document.",
      "200-content-range (the control got 200 with Content-Range bytes 400-999/1000 and 600 body bytes; reference placement: whole representation, which does not yield the document): curl, go-getter, grab, nugget, GNU Wget, GNU Wget2, yt-dlp finished the file by keeping the partial; HTTPie, huggingface_hub, node-downloader-helper discarded the partial and kept the response body alone as the file (600 bytes).",
      "always-416 (the control got 416 with Content-Range bytes */1000 and 0 body bytes; reference placement: none (the 416 names a length of 1000 against a partial of 400 bytes, and places no byte)): go-getter, grab, HTTPie, huggingface_hub, node-downloader-helper, nugget, yt-dlp stopped with an error and left the partial untouched; curl, GNU Wget, GNU Wget2 reported no error and left the partial untouched.",
      "unknown-total (the control got 206 with Content-Range bytes 400-999/* and 600 body bytes; reference placement: bytes 400-999, which yields the document): curl, go-getter, grab, HTTPie, node-downloader-helper, nugget, GNU Wget, GNU Wget2, yt-dlp finished the file by keeping the partial; huggingface_hub stopped with an error and left the partial untouched.",
      "if-range-ignored (the control got 206 with Content-Range bytes 400-999/1000 and 600 body bytes; reference placement: bytes 400-999, which does not yield the document): all 10 clients wrote a file that is not the document (shape mixed-generation).",
      "First request on a resume row: curl, HTTPie, huggingface_hub, GNU Wget, GNU Wget2 opened with a Range GET; go-getter, grab, node-downloader-helper opened with a HEAD; nugget, yt-dlp opened with a GET with no Range. 5 of 10 clients opened at least one resume row with a HEAD or a GET carrying no Range rather than a Range GET (go-getter, grab, node-downloader-helper, nugget, yt-dlp). The harness never sends a Range header itself, so each client chose what to ask for from the size of the partial file.",
      "Validators: none of the 224 requests the clients sent carried If-Range, If-Match, If-None-Match or If-Modified-Since, so no row here puts a stale validator to a server.",
      "curl is the one client that stopped on ignore and advertise-only: lib/http.c accepts the answer to a resume only when its Content-Range begins at the offset curl asked for, and anything else is CURLE_RANGE_ERROR, exit 33, \"HTTP server doesn't seem to support byte ranges. Cannot resume.\" The same rule is why curl completed 200-content-range: the status is 200, but the Content-Range starts at 400, and curl reads the header, not the status.",
      "A 416 whose Content-Range says */1000 against a 400-byte file read as completion to curl, GNU Wget and GNU Wget2: curl's http.c treats a 416 to a resume as \"no error\" and discards the body (exit 0); wget and wget2 print \"The file is already fully retrieved; nothing to do.\" and exit 0. The 400-byte partial stays, and nothing tells the caller the file is 600 bytes short.",
      "grab and go-getter decide whether to resume from the HEAD they send first: only a 200 HEAD carrying Accept-Ranges: bytes makes them send a Range, and neither reads the Content-Range of the answer (grab's client.go carries a \"// TODO: check Content-Range\"). So on ignore, whose HEAD advertises nothing, they sent no Range and rewrote the file; on advertise-only, whose HEAD advertises ranges and whose answer to the Range is a 200, they appended the whole body after the partial; and on always-206, whose HEAD is itself a 206, they sent no Range and took the full body.",
      "GNU Wget2 appends whatever comes back once it has sent a Range: it opens the output for append on a 206 and, with -O, on a 200 as well. nugget opens with flags \"a\" whenever -c is given, whether or not it sent a Range (on ignore, whose first answer advertised no ranges, it sent none), and reads Content-Range only for its progress bar. Both wrote the full 1,000-byte body of a 200 after the 400-byte partial on ignore and advertise-only.",
      "HTTPie, huggingface_hub and node-downloader-helper start over on a 200 whatever its headers say — HTTPie truncates unless the status is 206, huggingface_hub seeks back and truncates when a resume is answered with a 200, node-downloader-helper resets and truncates — and the body they then keep as the whole file is the 600-byte range the Content-Range described. Each trusted the status over the header; curl, wget, wget2, nugget, grab, go-getter and yt-dlp trusted the header, or did not look, and completed.",
      "HTTPie is the one client that stopped on the total: its parse_content_range requires last-byte-pos + 1 to equal the complete length, so \"bytes 400-999/2000\" is a ContentRangeError before a byte is written. The other nine completed the file; of them only huggingface_hub read the total at all, afterwards, in the consistency check described below.",
      "huggingface_hub reads the complete length as int() of whatever follows the slash in Content-Range, so \"bytes 400-999/*\" raises ValueError before anything is written; the other nine took the bytes and completed.",
      "On from-zero, the three clients that compare the Content-Range start with the offset they asked for — curl, HTTPie, GNU Wget — stopped with the partial untouched; yt-dlp compares it too, but on a mismatch it discards the partial and takes the body, which here is the whole document, so it completed; the other six appended 1,000 bytes after 400 without comparing the start with their offset (huggingface_hub then raised OSError when the 1,400-byte file did not match the 1,000-byte total).",
      "On no-content-range the same three stopped (a 206 without Content-Range is a range error to each), yt-dlp discarded the partial and kept the 600-byte body alone (\"Unable to resume\"), and the other six appended — which, this once, is where the bytes belonged.",
      "On off-by-one, 599 bytes arrive under a Content-Range that promises 600: HTTPie and huggingface_hub wrote them and then reported the shortfall (\"Incomplete download: size=1000; downloaded=999\"; \"Consistency check failed: file should be of size 1000 but has size 999\"); GNU Wget takes its expected length from the Content-Range rather than Content-Length, so it waited on the kept-alive connection for a 600th byte the response had already said it would not send, and the harness cap ended it; the other seven exited 0 with a 999-byte file.",
      "All ten clients mixed generations on if-range-ignored and every one exited 0. None sent If-Range or any other validator with its resume — and this flavor ignores If-Range by design, so a validator would not have changed the answer; what the rows show is that no client here reports a document that changed under it.",
      "huggingface_hub completed the file on wrong-total and on no-content-range and still raised OSError: its consistency check after the download compares the file size with the Content-Range total (2000) or, absent a Content-Range, with the Content-Length of the range body (600), so the caller gets an OSError for a file whose 1,000 bytes match the document.",
      "2 of 150 rows hit the harness's 30 s cap (GNU Wget on off-by-one, 1 request made and the file at 999 bytes, GNU Wget on shifted, 1 request made and the file at 999 bytes) and 0 failed to land. Every other row is a response this server sent, read back from the wire with its x-badhttp-version on every exchange."
    ],
    "what_the_rows_cannot_say": "What a client does over HTTPS or HTTP/2 (every client spoke HTTP/1.1 to a loopback recorder), what a segmented downloader does with advertise-only (nothing here is large enough to split: aria2 splits only above 2 MiB), what a client does with a suffix range (no resumer sends one, so suffix-as-prefix is served to a resume request as it would be to any other), how a browser's download manager resumes (no browser in the roster), what aria2 does (it resumes only in 16 KiB blocks and only from its own control file, so a 1,000-byte document cannot be \"400 bytes done\" to it; a separate row set at 65,536 bytes with a 32,768-byte partial is the follow-up), and anything after the 30 s cap.",
    "not_in_roster": [
      {
        "client": "axel",
        "reason": "It retries without bound on a bad 206 (about 115 requests in 12 s in the survey of 2026-10-12), which would trip the zone rate limit."
      },
      {
        "client": "pySmartDL",
        "reason": "It restarts from zero rather than resuming a bare partial file."
      },
      {
        "client": "ipull",
        "reason": "It restarts from zero rather than resuming a bare partial file."
      },
      {
        "client": "pip",
        "reason": "Its resume exists only in-process, after a dropped connection; it does not resume a partial file left on disk."
      },
      {
        "client": "plain HTTP libraries",
        "reason": "They send only the Range header the caller typed, so the choice of what to ask for is not theirs."
      }
    ],
    "reproduce": "Write the first 400 bytes of GET /range/ok?length=1000 to a fresh file, point the row's client at the row's url with the instruction to resume that file through a recording proxy, and compare the file and the exit with the row; for the reference, fetch the same url with curl -sS --http1.1 -H 'Range: bytes=400-' and place the response as RFC 9110 §15.3.7 says. Pace the calls against the zone limit of 100 per 10 s, and treat a response without x-badhttp-version as no observation. The harnesses that produced the rows are in scripts/range-witness/ in the source."
  }
}
