eclipse-ee4j / eclipse-ee4j/jersey

InboundMessageContext fails with multiple identically content types

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

Description

I wanted to report an issue I had with this library, but I want to be clear that I totally understand if you don't feel this is a problem/important enough.

[InboundMessageContext](https://github.com/eclipse-ee4j/jersey/blob/master/core-common/src/main/java/org/glassfish/jersey/message/internal/InboundMessageContext.java#L324) enforces a single value for certain headers (example ["Content Type"](https://github.com/eclipse-ee4j/jersey/blob/master/core-common/src/main/java/org/glassfish/jersey/message/internal/InboundMessageContext.java#L450); you can find the RFC definition for this header [here](https://tools.ietf.org/html/rfc7231#section-3.1.1.5)).

This is probably a reasonable configuration but it leads to errors such as the following:
```
Too many "Content-Type" header values: "[application/json;charset=utf-8, application/json;charset=utf-8]"
```

For completeness I've made sure that these values are byte for byte identical (ignoring the comma and whitespace).

It seems that while the client sending this payload is misconfigured (we believe we've observed this from webbrowsers), the intent is clear. It would be convenient to either have the underlying library identify such cases or provide some configuration such that consuming code could choose how to handle this.

Again, I totally understand if this is low priority or against the design philosophy of this library, I just wanted to make an attempt to see if there was something that could be done.

Contributor guide

Open the contributing guide

Research direction

Start in core-common/src/main/java/org/glassfish/jersey/message/internal/InboundMessageContext.java, especially the linked header-processing locations around lines 324 and 450. Reproduce the duplicate, byte-identical Content-Type values and inspect how the current single-value enforcement produces the error. Done should be a reviewed, project-consistent way to handle this case or configure its handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.