开发者

How to change HTTP request version to 1.0 using PowerShell

开发者 https://www.devze.com 2023-02-19 00:20 出处:网络
In C# I can override WebClient.GetWebRequest method in order to change HTTP version. prote开发者_高级运维cted override WebRequest GetWebRequest(Uri uri)

In C# I can override WebClient.GetWebRequest method in order to change HTTP version.

prote开发者_高级运维cted override WebRequest GetWebRequest(Uri uri)  
{  
    HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);        
    request.ProtocolVersion = System.Net.HttpVersion.Version10;  

    return request;  
}

I have to change HTTP request version to 1.0 before invoking web service using New-WebServiceProxy.

Is there a way to change this?


Set the ProtocolVersion field to version10. Like so,

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

Mind you, unlike C#, Powershell (and .Net API bindings) are note case sensitive.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号