Open sdelamo opened 5 years ago
What problem is this causing?
There are servers that implement only stricter interpretation of RFC3986 only accepting %20 encoding of space and not +
While workaround is trivial of replacing+ with %20 after getting URI string, would be better if the framework supported it directly.
Thanks
I spent a hour troubleshooting broken url because UriBuilder does not encode in path() and native URLEncoder.encode produces garbage which failed deep inside io.micronaut.http.uri.UriTemplateMatcher#rejectCharacter
because it rejects +. For now I hack it with manual replacement https://stackoverflow.com/a/611117/7991462. It definitely should be handled internally
[HTML spec](https://www.w3.org/TR/html4/interact/forms.html#h-17.13.4)
says that forapplication/x-www-form-urlencoded
space characters should be replaced by+
.It seems https://tools.ietf.org/html/rfc3986 recommends to use %20 for space characters.
In
io.micronaut.http.uri.DefaultUriBuilder::encode
we usejava.net.URLEncoder.encode
which replaces spaces characters with with+
.Maybe we could use add a method to
UriBuilder
namedmediaType(MediaType mediaType)
.The default value of mediaType could be
APPLICATION_FORM_URLENCODED_TYPE
to avoid a breaking change.If you pass something such as
MediaType.TEXT_PLAIN_TYPE
we use%20
instead of+
e.g.
thoughts?