Bla*_*ake 5 java scala url-encoding rabbitmq scala-dispatch
我正在使用Scala的Dispatch如下:
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)
Run Code Online (Sandbox Code Playgroud)
在%2f
被变成了/
,所以它会试图张贴到/api/queues///myQueue/get
而不是/api/queues/%2f/myQueue/get
.
我该如何妥善逃脱?
% 符号用于 url 编码。因此,%2f 被解码为 /。在浏览器上尝试一下,你就会看到。
使用%25代表%符号。例如
val req = url("http://localhost:4567/api/queues/%252f/myQueue/get")
Run Code Online (Sandbox Code Playgroud)