Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change HTTP request version to 1.0 using PowerShell

Tags:

powershell

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

protected 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?

like image 840
Sasha Korman Avatar asked Sep 13 '25 13:09

Sasha Korman


1 Answers

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.

like image 180
vonPryz Avatar answered Sep 16 '25 07:09

vonPryz