gpt4 book ai didi

powershell - 如何使用 PowerShell 将 HTTP 请求版本更改为 1.0

转载 作者:行者123 更新时间:2023-12-03 18:32:55 25 4
gpt4 key购买 nike

在 C# 中,我可以覆盖 WebClient.GetWebRequest 方法以更改 HTTP 版本。

protected override WebRequest GetWebRequest(Uri uri)  
{
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
request.ProtocolVersion = System.Net.HttpVersion.Version10;

return request;
}

在使用 New-WebServiceProxy 调用 Web 服务之前,我必须将 HTTP 请求版本更改为 1.0。

有没有办法改变这个?

最佳答案

将 ProtocolVersion 字段设置为 version10。像这样,

$hr = [system.net.httpwebrequest]::create("http://www.example.com")
$hr.ProtocolVersion = [system.net.httpversion]::version10

请注意,与 C# 不同,Powershell(和 .Net API 绑定(bind))区分大小写。

关于powershell - 如何使用 PowerShell 将 HTTP 请求版本更改为 1.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5405276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com