Handle encoding characters like `%^{}\|; for query parameters in HttpRoutes
See original GitHub issueDescription:
If we have to create route with some parameters, like:
case GET -> Root / "data" :? CodeQueryParam(code) +& ShowCurrentDataQueryParam(showCurrentData)
object ShowCurrentDataQueryParam extends OptionalQueryParamDecoderMatcher[Boolean]("showCurrentData")
object CodeQueryParam extends QueryParamDecoderMatcher[String]("code")
And call API with:
http://localhost:8888/data?code=%&showCurrentData=true
or
http://localhost:8888/data?code=111111&showCurrentData=^
We receive 400 Bad Request with no message.
Expected result: Handle this characters properly or receive corresponding message
Actual result: 400 Bad Request with no message
Version: 1.0.0-M5
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How can I include special characters in query strings?
You have to encode special characters in URLs. ... You need to encode the query parameters before combining them to form a url....
Read more >Using URL encoding to handle special characters in a ...
Consider the example where a parameter is supplied in a URL and parameter value has a special character in it, such as,.
Read more >Unleashing the Power of HTTP Apis: The Http4s Library
Through the DSL, we build an HttpRoutes[F] using pattern matching as a sequence of ... If we have to handle more than one...
Read more >The http4s DSL
The central concept of http4s-dsl is pattern matching. An HttpService[F] is declared as a simple series of case statements. Each case statement ...
Read more >Using Special Characters in Query String - Caspio Online Help
This issue can be avoided by encoding the special characters using Caspio Calculated Field before using them in Query String. Prerequisites:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I left a comment here originally about a separate but similar issue, and realized it would make more sense in a new issue (#4203), sorry for any inconvenience 🙏 it’s deleted now.
The valid characters are alphanumerics and:
/ ? : @ - . _ ~ ! $ & ' ( ) * + , ; =
. Everything else needs to be percent-encoded to make a valid URI.It’s the backends that are rejecting this.
Http4sServlet
, which responds with an “Invalid request target” message in the body of the 400.Even if the http4s parser got more lenient, many servers won’t, so I’d urge you to fix the requests. But we’ll make Blaze at least as informative as Jetty here.