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

WebClient's UriBuilder option should encode path parameters passed into build [SPR-17465] #21997

spring-issuemaster opened this Issue Nov 5, 2018 · 2 comments


None yet
2 participants
Copy link

spring-issuemaster commented Nov 5, 2018

Benjamin Conlan opened SPR-17465 and commented

When using the reactive web WebClient's uribuilder building a Uri path value doesn't get encoded as expected:

(Excuse code here... Composed from phone)

webClient.get().uri(builder -> builder.path("/{test}").build("encode/this"))

Behaves differently to:

webClient.get().uri("/{test}", "encode/this")

I would expect the url path segment in the 1st case to also be encoded.

Affects: 5.0.8

Issue Links:

  • #22064 WebClient no longer encodes query parameters ("is duplicated by")

Referenced from: commits 2405161, e4c84ec

Backported to: 5.0.11


This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 7, 2018

Rossen Stoyanchev commented

Indeed there is an issue.

The explanation is made a little more complicated by the fact that in 5.1, the encoding mode for DefaultUriBuilderFactory changed as part of the work for #21577. Prior to 5.1 the encoding mode was URI_COMPONENTS where if you use path(..), as opposed to pathSegment(..), then "/" is allowed and therefore not encoded. So technically this example is not a regression, but using pathSegment in 5.1 does not work either because which is a regression.

After the change to encoding mode TEMPLATE_AND_VALUES in 5.1, URI variables should be strictly encoded, regardless of whether you use path or pathSegment, due to a bug when using the builder option. After the fix both of the above examples should encode as expected.

For more background on those options see the reference docs.


This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 9, 2018

Rossen Stoyanchev commented

Benjamin Conlan I updated my previous comment to say 5.1 (instead of 5.0.8), as it should have been.

For 5.0.x the example you gave is expected behavior I'm afraid. You would have to use pathSegment("{test}") instead of path("/{test}"), or as of 5.0.11 (i.e. after the fix) switch the encoding mode from URI_COMPONENT to TEMPLATE_AND_VALUES.

For 5.1.x after the fix in 5.1.3 the example should just work since in 5.1.x the default encoding mode is TEMPLATE_AND_VALUES by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.