Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add-type @"
- using System.Net;
- using System.Security.Cryptography.X509Certificates;
- public class TrustAllCertsPolicy : ICertificatePolicy {
- public bool CheckValidationResult(
- ServicePoint srvPoint, X509Certificate certificate,
- WebRequest request, int certificateProblem) {
- return true;
- }
- }
- "@
- [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
- $url = $args[0]
- if ($args[1]) { [int]$keepalive = $args[1] } else { $keepalive = 15 }
- $progressPreference = 'silentlyContinue'
- write-host "Creating initial connection to $url" -NoNewline
- $initialconnection = measure-command {
- $result = Invoke-WebRequest -Uri $url -UseBasicParsing
- }
- write-host -ForegroundColor Green " Done"
- if ($result.Headers["Keep-Alive"] -match "timeout=([0-9]{0,3})")
- {
- [int]$keepalive = $Matches[1]
- $keepalive = $keepalive + 2
- write-host "Waiting $keepalive seconds to let the server clear the connection"
- }
- else
- {
- write-host "Waiting DEFAULT $keepalive seconds to let the server clear the connection"
- }
- sleep $keepalive
- write-host "Creating session resumption request to $url" -NoNewline
- $resumeconnection = measure-command {
- $result = Invoke-WebRequest -Uri $url -UseBasicParsing
- }
- write-host -ForegroundColor Green " Done"
- write-host "Creating keepalive request to $url" -NoNewline
- $keepaliverequest = measure-command {
- $result = Invoke-WebRequest -Uri $url -UseBasicParsing
- }
- write-host -ForegroundColor Green " Done"
- write-host "Initial connection: " $initialconnection.TotalMilliseconds
- write-host "Resume connection: " $resumeconnection.TotalMilliseconds
- write-host "KeepAlive request: " $keepaliverequest.TotalMilliseconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement