如何强制Uri
或HttpWebRequest
允许包含两者的uri /
,%2f
如下所示?
http://localhost:55672/api/exchanges/%2f/MyExchange
我试过这个...
WebRequest request =
HttpWebRequest.Create("http://localhost:55672/api/exchanges/%2f/MyExchange");
...还有这个...
Uri uri = new Uri("http://localhost:55672/api/exchanges/%2f/MyExchange", true);
WebRequest request = HttpWebRequest.Create(uri);
...还有这个...
UriBuilder builder = new UriBuilder();
builder.Port = 55672;
builder.Path = "api/exchanges/%2f/MyExchange";
WebRequest request = HttpWebRequest.Create(builder.Uri);
但是,所有这些request.RequestUri
最终http://localhost:55672/api/exchanges///MyExchange
都会request.GetResponse()
产生 404 响应。
仅供参考,我正在尝试使用 RabbitMQ 的 HTTP API 并在 Chrome 中键入 Url 会产生预期的 JSON 结果。