-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Disallow negative or hexadecimal content-length headers. #49305
Copy link
Copy link
Closed
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.breaking-change-requestThis tracks requests for feedback on breaking changesThis tracks requests for feedback on breaking changesenhancement-breaking-changeAn enhancement which is breaking.An enhancement which is breaking.library-_http
Milestone
Metadata
Metadata
Assignees
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.breaking-change-requestThis tracks requests for feedback on breaking changesThis tracks requests for feedback on breaking changesenhancement-breaking-changeAn enhancement which is breaking.An enhancement which is breaking.library-_http
Change
Generate a
HttpExceptionwhenHttpHeaders.add(...)encounters a negative or hexadecimal encodedcontent-length. Currently both are acceptable.Also, change non-numeric input to raise a
HttpExceptionrather than aFormatExceptionso that a consistentExceptionis thrown.Rationale
RFC 7230 says that the production for
content-lengthis:So we are currently accepting invalid input that might cause clients/servers to misbehave.
The possibility of
HttpHeaders.add(...)throwingFormatExceptionis undocumented so (partially) consolidate toHttpException(which is what is what is thrown for most parse failures).Impact
This change does not break any Google tests.
Note that this does not change the semantics of the
HttpHeaders.contentLengthproperty where a negative value means remove the header completely.Mitigation
Users should not use
HttpHeaders.add(...)to setcontent-lengthheaders that are not allowed by the RFC.