eclipse-ee4j / eclipse-ee4j/jersey

The HTTP parser of JdkConnector fails to parse valid date headers

Open
#4,995 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

Using `JdkConnectorProvider` for a ws-rs client breaks `ClientResponseContext.getLastModified()` because its `HttpParser` splits a valid `Last-Modified` header on `,` (comma) into two values. Date headers always contain (unquoted) comma. This triggers `org.glassfish.jersey.message.internal.HeaderValueException: Too many "Last-Modified" header values: "[Wed, 2 Mar 2022 18:03:55 GMT]` because `InboundMessageContext` (correctly) expects this header to only have one value.

See https://github.com/eclipse-ee4j/jersey/blob/7b6d2f84391f24310baae7d8e55e644703642826/connectors/jdk-connector/src/main/java/org/glassfish/jersey/jdk/connector/internal/HttpParser.java#L407 and https://github.com/eclipse-ee4j/jersey/blob/7b6d2f84391f24310baae7d8e55e644703642826/connectors/jdk-connector/src/main/java/org/glassfish/jersey/jdk/connector/internal/HttpParser.java#L463

Splitting date headers into multiple values this way is always wrong. I find it odd that splitting is the default here. There might be other headers (e.g. custom headers starting with `X-`) that may allow unquoted comma in their value.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.