Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass %2f to java.net.URI without it being turned into /

I'm using Dispatch from Scala as follows:

val body = """{"count":5,"requeue":true,"encoding":"auto","truncate":50000}"""
val req = url("http://localhost:4567/api/queues/%2f/myQueue/get").as_!("guest", "guest") << (body, "application/json")

val http = new Http

val resp = http(req as_str)

The %2f gets turned into a /, so it tries to post to /api/queues///myQueue/get rather than to /api/queues/%2f/myQueue/get.

How do I escape this properly?

like image 790
Blake Avatar asked Nov 13 '22 01:11

Blake


1 Answers

% sign is used in url encoding. So, %2f gets decoded into /. try it on browser and you will see.

Use %25 to represent % sign. e.g.

val req = url("http://localhost:4567/api/queues/%252f/myQueue/get")
like image 109
Johnny Everson Avatar answered Nov 14 '22 22:11

Johnny Everson