Reputation: 4640
I would like to make a simple GET
request via Spray with a few query parameters
Get("http://localhost/[email protected]")
However +
means a space in application/x-www-form-urlencoded content resulting the call to http://localhost/user?email=abc [email protected]
(with a space instead of plus sign).
I could use a non-Spray java.net.URLEncoder
to encode the URL before passing it to the GET request however I doing this every time seems like a hack.
Is there a Spray way of applying query parameters and encoding them?
Uri("http://localhost/").withQuery(Map("email"->"[email protected]"))
is a nice way to construct a Uri but it doesn't encode the params as well...
Upvotes: 0
Views: 1389
Reputation: 4640
Actually Uri("http://localhost/").withQuery(Map("email"->"[email protected]"))
works fine as it encodes the special symbols.
However, Uri("http://localhost/").withQuery("[email protected]")
doesn't.
Upvotes: 3
Reputation: 1420
I use java.net.URLEncoder. I believe that is the accepted method. It would be nice if that happened automatically!
Upvotes: 0