相关疑难解决方法(0)

使用url编码的斜杠获取URL

我想发送一个HTTP GET http://example.com/%2F.我的第一个猜测是这样的:

using (WebClient webClient = new WebClient())
{
  webClient.DownloadData("http://example.com/%2F");
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,我可以看到实际上在线上发送的是:

GET // HTTP/1.1
Host: example.com
Connection: Keep-Alive
Run Code Online (Sandbox Code Playgroud)

因此http://example.com/%2F在传输之前会被翻译成http://example.com //.

有没有办法实际发送此GET请求?

当使用OCSP over HTTP/GET时,OCSP协议要求发送base-64编码的url编码,因此必须发送实际的%2F而不是'/'才能兼容.

编辑:

以下是OCSP协议标准(RFC 2560附录A.1.1)的相关部分:

使用GET方法的OCSP请求构造如下:

GET {url}/{对OCSPRequest的DER编码的base-64编码的url编码}

我对其他读物非常开放,但我看不出还有什么意思.

.net c# base64 http url-encoding

35
推荐指数
3
解决办法
3万
查看次数

如何使System.Uri不在路径中转换%2f(斜杠)?

System.Uri构造函数坚持将%2f序列转义为foward斜杠,当它在URL的路径部分中看到它们时.我怎么能避免这种行为?

我已经看到了这个thig上的Connect票证,但据我所知,解决办法对.net 4不起作用.

.net

11
推荐指数
1
解决办法
3776
查看次数

Powershell - Invoke-WebRequest到一个带有文字'/'(%2F)的URL

我一直在尝试/使用以下命令从powershell 访问带有字符的URL (它是对gitlab服务器的查询以检索调用的项目"foo/bar"):

Invoke-WebRequest https://server.com/api/v3/projects/foo%2Fbar -Verbose
Run Code Online (Sandbox Code Playgroud)

现在,奇怪的是使用PowerShell ISE或Visual Studio,请求是正常的.使用PowerShell本身时,URL会自动取消转义,并且请求失败.例如

在ISE/VS中:

$> Invoke-WebRequest https://server.com/api/v3/projects/foo%2Fbar -Verbose
VERBOSE: GET https://server.com/api/v3/projects/foo%2Fbar with 0-byte payload
VERBOSE: received 19903-byte response of content type application/json

StatusCode        : 200
StatusDescription : OK
Content           : .... data ....
Run Code Online (Sandbox Code Playgroud)

在Powershell中:

$> Invoke-WebRequest https://server.com/api/v3/projects/foo%2Fbar -Verbose
VERBOSE: GET https://server.com/api/v3/projects/foo/bar with 0-byte payload
Invoke-WebRequest : {"error":"404 Not Found"}
At line:1 char:1
+ Invoke-WebRequest 'https://server.com/api/v3/projects/foo%2Fbar ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Run Code Online (Sandbox Code Playgroud)

我尝试在URL周围添加单引号和双引号,但没有任何帮助. …

url powershell webrequest urlencode

7
推荐指数
1
解决办法
4000
查看次数

标签 统计

.net ×2

base64 ×1

c# ×1

http ×1

powershell ×1

url ×1

url-encoding ×1

urlencode ×1

webrequest ×1