Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-1172: Store expanded Header Template values as Literals #1203

Merged

Conversation

kdavisk6
Copy link
Member

@kdavisk6 kdavisk6 commented Apr 7, 2020

Fixes #1172

When a HeaderTemplate is expanded, the result is placed onto a new
RequestTemplate via it's header method. This results in the expanded
result being turned back into a HeaderTemplate, simply out of
convenience. This behavior, while fine more general use cases, is
problematic if the header value contains braces { }, as this will
cause the app to consider these values as new expressions.

At this point in the expansion process, there is no need to evaluate
the expanded values again, so this change allows a Template to be
created from an existing List of TemplateChunks, allowing for callers
to provide explicit Literal or Expression chunks directly into a
Template, by passing the template parsing algorithms.

RequestTemplate#expand has been updated to apply this logic for
HeaderTemplate values only.

Fixes OpenFeign#1172

When a `HeaderTemplate` is expanded, the result is placed onto a new
`RequestTemplate` via it's `header` method.  This results in the expanded
result being turned back into a `HeaderTemplate`, simply out of
convenience.  This behavior, while fine more general use cases, is
problematic if the header value contains braces `{` `}`, as this will
cause the app to consider these values as new expressions.

At this point in the expansion process, there is no need to evaluate
the expanded values again, so this change allows a `Template` to be
created from an existing List of `TemplateChunks`, allowing for callers
to provide explicit `Literal` or `Expression` chunks directly into a
`Template`, by passing the template parsing algorithms.

`RequestTemplate#expand` has been updated to apply this logic for
`HeaderTemplate` values only.
@kdavisk6 kdavisk6 added the bug Unexpected or incorrect behavior label Apr 7, 2020
@kdavisk6 kdavisk6 requested a review from velo April 7, 2020 01:58
Copy link
Member

@velo velo left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sending "{}" as header value fails since 10.2.0
2 participants