--- kind: CONCEPT slug: adapter-outbound-httpclient-c06 title: 와이어 바이트와 디코드 바이트를 따로 세고, 읽는 도중에 상한을 건다 topic: schema-and-wire-models project: clean-architecture-backend-template status: 게시 전 sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 rootTreeNode: concept:adapter-outbound-httpclient-c06 evidenceCapturedOn: 2026-09-01 assets: - key: adapter-outbound-httpclient-c06 file: ../../../final/evidence/rendered/adapter-outbound-httpclient-c06.svg - key: adapter-outbound-httpclient-c06-diagram file: ../../../final/assets/diagrams/adapter-outbound-httpclient-c06.svg evidence: - ../../../final/evidence/raw/adapter-outbound-httpclient-c06.txt source: - 원본 분석 절은 analysis/11-adapter-outbound-httpclient.md#L403 이다. module: adapter-outbound-httpclient --- # 와이어 바이트와 디코드 바이트를 따로 세고, 읽는 도중에 상한을 건다 예산이 둘로 나뉘어 있고 강제 시점이 버퍼링 이후가 아니라 읽는 도중이며, 원격이 준 status는 채택되지 않는다. ## 본문 `ResponseSizeLimiter`가 **와이어 바이트와 디코드 바이트를 따로** 센다 — "a compressed payload passes a wire check and then expands, so a single limit either rejects legitimate traffic or lets a **decompression bomb** through." ## 예산이 강제되는 자리 :::evidence key="adapter-outbound-httpclient-c06-diagram" alt="와이어 바이트 예산, 읽는 도중 상한 강제, 디코드 바이트 예산, 오류 본문 제한 읽기가 읽는 순서대로 쌓여 있다" caption="응답 크기 예산이 강제되는 자리" zoom="false" ::: ## 버퍼링이 끝난 뒤에는 늦다 `CountingBoundedInputStream`이 상한을 **읽는 도중에** 적용한다 — "a response that is discovered to be too large only once it is fully buffered has already cost the memory the limit exists to protect." `BoundedErrorBody`는 오류 본문을 RFC 9457 문서를 해독할 만큼만 읽고, "The bytes never reach an exception message or a log." `toString()`은 길이와 truncated 여부만 낸다. ## 원격이 준 status는 버린다 `RemoteProblemDecoder`의 규칙 한 줄이 이 계층의 성격을 요약한다 — "**The wire status wins.** A remote `status` member is read and discarded, because trusting it would let an upstream **relabel a 503 as a 400 and change our retry behaviour from its own body.**" 확장 속성도 allowlist로 걸러 "an upstream cannot inject unbounded attributes into our telemetry." test 넷이 그 갈래를 고정한다(`mapsProblemJsonWithoutTrustingBodyStatus`·`dropsExtensionsThatAreNotAllowlisted`·`treatsANonProblemContentTypeAsAnEmptyProblem`·`survivesAnUnparseableProblemDocument`). ## ResponseSizeLimiter 참조 위치 :::evidence key="adapter-outbound-httpclient-c06" alt="코드베이스에서 ResponseSizeLimiter 를 검색한 출력 20줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="ResponseSizeLimiter 코드베이스 검색 — 20줄 · exit 0" zoom="true" :::