http-range-response-testing
Verify HTTP byte-range server behavior on deterministic loopback routes across 206 Partial Content, Content-Range, 416, If-Range validators, suffix/open ranges, and multi-range.
Try your first task
A source-grounded starter task has not been verified for this skill yet.
SKILL.md
name: http-range-response-testingdescription: "Verify HTTP byte-range server behavior on deterministic loopback routes across 206 Partial Content, Content-Range, 416, If-Range validators, suffix/open ranges, and multi-range."category: developmentrisk: safesource: selfsource_type: selfdate_added: "2026-12-01"author: Koushik-Katkamtags: [http, rfc9110, range-requests, partial-content, testing, api]HTTP Range Response Testing
Overview
Run deterministic loopback HTTP tests grounded in RFC 9110 (HTTP Semantics, Sections 13.1.5 & 14) for endpoints that explicitly promise byte-range support (Accept-Ranges: bytes). Verifies exact response bytes, inclusive boundaries, open-ended and suffix ranges, 206 Partial Content + Content-Range, 416 Range Not Satisfiable, matching vs. stale If-Range, 200 OK fallback semantics, Content-Length consistency, and optional multipart/byteranges support.
Distinction from existing skills:
weather-model-data-fetching: covers client-side GRIB2.idxrange fetching from AWS S3/NOMADS (Range: bytes=START-END, expecting206without multipart) rather than auditing an HTTP server's RFC 9110 server-side range handler.http-status-code-tester: checks general URL status codes/redirects for SEO auditing without byte-range boundary,Content-Range, orIf-Rangeverification.api-contract-testing: focuses on consumer-provider schema contracts rather than RFC 9110 partial-content byte framing.
When to Use
- Testing custom file-streaming, CDN-proxy, artifact, or media API routes that advertise
Accept-Ranges: bytes. - Reproducing partial-download corruption caused by off-by-one byte slices, mismatched
Content-Length, staleIf-Rangereturning206, or broken416responses. - Distinguishing RFC 9110-permitted behavior (for example, ignoring
Rangeand returning200 OKwhen a server chooses not to serve partial responses) from route-contract violations when an endpoint explicitly promises206byte-range support. - Do not use this skill against external third-party URLs or production endpoints without explicit authorization.
Prerequisites
- Python
3.10+withpytest(tested with Python3.12.10stdlibhttp.server/http.clientandpytest==9.1.1). - No external HTTP clients or live network endpoints required; tests bind strictly to
127.0.0.1:0with bounded timeouts and deterministic cleanup.
How It Works
1. Distinguish RFC-permitted behavior from route promises
- Under RFC 9110 §14.2, a general origin server is allowed to ignore
Rangeand send200 OKwith the full representation;Accept-Ranges: bytesindicates advertised support rather than an irrevocable guarantee that every subsequentRangerequest will return206. - Similarly, RFC 9110 §15.5.17 / §14.4 classifies returning
Content-Range: bytes */<complete-length>on a416 Range Not Satisfiablebyte-range response as SHOULD, not MUST. - This harness enforces explicit application-contract assertions for partial-content routes (requiring
206on single satisfiable ranges unless triggered by stale/weakIf-Range, and requiringContent-Range: bytes */<complete-length>on416) while separating RFC MUST correctness bugs (off_by_one,stale_if_range_206,bad_content_length,missing_content_rangeon206) from route-contract policy checks.
2. Exercise bounded loopback fixtures
Run the local suite in HTTP range loopback harness:
- Exact slices & inclusive boundaries:
bytes=0-4returns206,Content-Range: bytes 0-4/32,Content-Length: 5, and exact 5 bytes (payload[0:5]); single-bytebytes=7-7returns 1 byte (bytes 7-7/32). - Open-ended & suffix ranges:
bytes=20-returnsbytes 20-31/32(12 bytes);bytes=-6returns the trailing 6 bytes (bytes 26-31/32); oversized suffixbytes=-999clamps tobytes 0-31/32. - Unsatisfiable ranges (
416):bytes=99-120on a 32-byte payload returns416,Content-Range: bytes */32, and empty body; malformed syntactic ranges (bytes=10-5or unsupported unitsitems=0-2) do not return206. - Conditional
If-Range(RFC 9110 §13.1.5): MatchingETagreturns206slice; stale/mismatchedETagforces200 OKfull representation with noContent-Range. - Multiple ranges (
multipart/byteranges): On routes declaring multi-range support,Range: bytes=0-3, 10-12returns206,Content-Type: multipart/byteranges; boundary=..., valid partContent-Rangeheaders, exact byte slices, and consistent outerContent-Length. - Non-vacuous negative mutations: Verify intentional bugs (
off_by_one,stale_if_range_206,wrong_416_status,bad_content_length) fail loudly.
Examples
Run the self-contained verification suite in HTTP range loopback harness:
User request: "Test our artifact download endpoint for RFC 9110 Range, If-Range, and 416 correctness."
Inputs: Loopback HTTP route fixture (127.0.0.1:0, 32-byte payload, ETag '"v1-payload"').
Expected result: All inclusive, open-ended, suffix, If-Range (match=206, stale=200), 416, fallback,
and multipart/byteranges assertions pass; broken server mutations (off-by-one, bad Content-Length,
stale If-Range 206, missing 416 Content-Range) fail with concrete diagnostic errors.
Limitations
- Tests local loopback fixtures over HTTP/1.1 (
http.client.HTTPConnection); reverse proxies, CDNs, HTTP/2 frame reassembly, and TLS termination can rewrite or stripRange/If-Rangeheaders in production. - The included loopback server's
_parse_range_headerhelper is a limited synthetic test-fixture parser (not a full RFC 9110 production parser; it omits optional whitespace variations, overlapping-range coalescing, and HTTP-dateIf-Rangevalidators). If-RangeHTTP-date validator parsing is omitted; only strong quoted ETag matching and weak ETag (W/"..."->200 OKfallback per RFC 9110 §13.1.5) are tested.- Non-2xx error behavior for empty (
0-byte) files is reported as unsatisfiable (416bytes */0) for byte-ranges and assumes static representation length.
Safety and Side Effects
- Strictly loopback-only (
127.0.0.1:0) using ephemeral OS-assigned ports and in-memory byte payloads with bounded2.0ssocket timeouts and deterministicserver.shutdown()+server.server_close()cleanup. - Never sends requests to external domains or modifies files on disk.