For an ordinary successful GET, record two different things: the coded bytes that arrived with the response representation, and the decoded UTF-8 bytes your client passes to the parser. Do not use character count as either byte count, and do not use Content-Length as len(decoded_body) when the response is compressed. This is an acceptance check for an authorized client integration, not a proxy bill calculation or a compression-performance claim.
Keep the three measures separate
HTTP defines representation data as the result of applying Content-Encoding to the content type. Thus an ordinary gzip response has coded bytes on the HTTP side and decoded bytes after the content coding is reversed. A UTF-8 character count is a third number: é and Chinese characters demonstrate why it cannot stand in for bytes. Content-Length, when present for this bounded case, compares with the coded representation, not the decoded body.
| Field | What to record | Do not infer |
|---|---|---|
| Coded bytes | Bytes handed to the decoding boundary before content decoding. | Total network wire bytes, headers, TLS records, or a supplier meter. |
| Decoded bytes | Bytes after exactly one supported content decoding; compare these to the expected UTF-8 payload. | What the server transferred before encoding. |
| Characters | Length after deliberate UTF-8 decoding, useful for text handling only. | Transfer, billing, quota, or storage bytes. |
Content-Length | Declared length of the coded body in this no-transfer-encoding example. | A required header, decoded length, or evidence of total wire use. |
RFC 9110 describes both Content-Encoding and Content-Length. An absent Content-Length is not automatically a failure. This guide deliberately excludes transfer encoding, range responses, redirects, multi-stage codings, trailers and ambiguous framing; use the client or protocol stack designed for those cases.
Run a controlled same-body comparison
Download the offline Python example. It creates one fixed UTF-8 JSON representation, then sends that same representation through synthetic identity and gzip cases. It makes no request, opens no proxy, and does not measure any provider.
python3 proxy-response-compression-checks.py
identity: coded_bytes=119 decoded_bytes=119 characters=102 declared_content_length=119 decoded_body_equal=True gzip: coded_bytes=110 decoded_bytes=119 characters=102 declared_content_length=110 decoded_body_equal=True identity_no_content_length: coded_bytes=119 decoded_bytes=119 characters=102 declared_content_length=absent decoded_body_equal=True mismatched_declared_length: HOLD (declared Content-Length differs from coded bytes) truncated_gzip: HOLD (gzip body cannot be completely decoded) unsupported_encoding: HOLD (unsupported Content-Encoding: br) checks_completed=6 accepted=3 held=3
The numeric relationship is synthetic and may even be unfavorable for this short payload; it is not a proxy compression ratio or a savings estimate. The fixture explicitly selects gzip level 9 and mtime=0 to make this run reproducible, but does not promise an identical gzip byte sequence across zlib/runtime versions. The acceptance rule is instead stable: identity and gzip must decode to the exact same bytes; a missing length may still be accepted; a mismatched declared coded length, incomplete gzip stream, or unsupported coding must stop the body before parsing.
Exactly once: place the check at the client boundary
Choose one layer that owns content decoding. Store its content_encoding, coded_body_bytes, decoded_body_bytes, content_length_present, content_length_value, decoder result, and a non-sensitive body fingerprint. The parser receives decoded bytes once. A second decompression attempt is a client bug, not a normal retry.
Requests Quickstart documents automatic decoding for gzip and deflate response data exposed through normal content access, while r.raw is the streaming interface. That distinction is useful for locating a measurement boundary; neither object is a total-wire or provider-billing meter. Check the behavior of the exact Requests version and streaming configuration in your integration. Python’s gzip.decompress is used only for the local, already-coded example.
Illustrative only; not run in this environment: a streaming Requests integration can take ownership of coded bytes at one boundary, then decode only there. Production code needs its own timeout, body-size, status and permitted-target rules.
import gzip
import requests
r = requests.get(url, stream=True, timeout=10)
coded = r.raw.read(decode_content=False)
coding = r.headers.get("Content-Encoding", "").lower()
if coding in ("", "identity"):
decoded = coded
elif coding == "gzip":
decoded = gzip.decompress(coded)
else:
raise ValueError("unsupported Content-Encoding")
# Validate decoded before parsing.
Acceptance checklist for a representative permitted target
- Pick an authorized, non-sensitive GET response and record client version, route label, timestamp, request context, status, and whether a direct identity control is permitted.
- Run a direct identity control only where the server actually selects identity.
Accept-Encodingexpresses what the client can accept; it does not guarantee the server’s choice. - Run the same defined request through the intended client path. Compare semantic response identity using an approved fingerprint or parsed contract, not an assumption that every upstream header is identical.
- For each accepted response, retain coded and decoded byte counts separately. If a declared length is present in this simple case, compare it to coded bytes. Do not replace a missing length with zero.
- Hold and investigate a decode error, unsupported coding, coded-length mismatch, unexpected body contract, access restriction, or response whose context cannot be matched. Do not silently retry by changing exits to bypass a restriction.
What this can and cannot tell a buyer
A successful local test only proves that this narrow client rule handled its synthetic representations. It does not establish IPHTML compression behavior, proxy bytes billed, price, latency, success rate, server choice, target permission, or provider performance. Before comparing any usage evidence, use the billing-evidence guide to align account, period and meter basis; use workload sizing for forecasts. Neither substitutes for a documented provider meter definition.
If an authorized recurring workflow still needs a residential route after direct controls, review residential proxies. For a bounded integration review, contact us with the permitted target category, client library, required content codings, expected decoded contract, and stop conditions—never credentials or protected content.
Sources checked December 5, 2026: RFC 9110 sections 8.4 and 8.6; Requests Quickstart response-content guidance; Python 3.15.2 gzip documentation. Actual output depends on the local Python/zlib runtime. The fixture, payload, outputs and acceptance decisions are synthetic. It makes no commercial, billing, performance, availability, or outcome claim.