Skip to content

Treat runtime HeaderMap values as literals - #3612

Merged
velo merged 1 commit into
OpenFeign:masterfrom
hutiefang76:frank/newten-feign-headers-20261010-01a11186
Nov 9, 2026
Merged

velo merged 1 commit into
OpenFeign:masterfrom
hutiefang76:frank/newten-feign-headers-20261010-01a11186

Conversation

@hutiefang76

Copy link
Copy Markdown
Contributor

Runtime @HeaderMap values currently go through URI template parsing. A valid header containing a braced literal longer than the URI expression limit throws before the HTTP request is sent; the same problem occurs in a quoted Content-Type parameter.

Use the existing literal header path for runtime maps, and honor it in the Content-Type special case. Preserve annotated header expansion and the existing rule that only the first Content-Type value is sent. Add regressions for large JSON and quoted media-type values, plus compatibility coverage and a changelog entry.

Validation: the affected FeignTest, RequestTemplateTest and ExpressionsTest classes pass 132 tests. With the original implementation, the two large-value regressions fail before the request is sent. The full core-module verify with the development profile passes: 777 reported tests, 773 executed successfully and 4 skipped by the project configuration. License and format checks remain enabled; the other integration modules were not run.

AI assistance was used for investigation, implementation and source review.

Use literal headers for runtime maps, including Content-Type, while retaining annotation template expansion and first Content-Type selection.

Signed-off-by: hutiefang76 <137664623+hutiefang76@users.noreply.github.com>

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the compatibility angle: @HeaderMap headers are added after resolve(), so template expressions in their values were never expanded anyway. They were echoed back via Expression.toString() or threw on long/unparseable values, so treating them as literals only removes the failures. The Content-Type branch now honours the literal flag too, which also stops resolve() from re-parsing an already-expanded Content-Type. CHANGELOG entry and tests look good. Nit: the inline comment in addHeaderMapHeaders is redundant with headerLiteral.

@velo
velo merged commit 893683e into OpenFeign:master Nov 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants