Skip to content

Instantly share code, notes, and snippets.

@fearthecowboy
Created June 18, 2019 18:04
Show Gist options
  • Save fearthecowboy/f9ba491ee893525fa84a75b4b9018f08 to your computer and use it in GitHub Desktop.
Save fearthecowboy/f9ba491ee893525fa84a75b4b9018f08 to your computer and use it in GitHub Desktop.
quick peek
-HttpPipelineAppend { param($req, $callback, $next )
Write-Host -fore white "Inserted my code in the http pipeline on the way to:`n $($req.RequestUri)."
Write-Host -fore yellow "`n---------------------`n Before We Go!`n---------------------"
Write-host -fore white "Request Headers:";
$($req.Headers) |% { if ($_.Key -ne "Authorization") { Write-host -nonewline -fore cyan " $($_.Key): "; Write-Host -fore green "$($_.Value)" } }
# call the next step in the Pipeline
$responseTask = $next.SendAsync($req, $callback)
# wait on the responseTask
$response = $responseTask.Result
# after the call...
Write-Host -fore yellow "`n---------------------`nWe're back!`n---------------------"
# Peek into the http response before it goes to the cmdlet for processing
Write-host -fore white "Response Headers:";
$($response.Headers) |% { Write-host -nonewline -fore cyan " $($_.Key): "; Write-Host -fore green "$($_.Value)" }
write-host -fore green ($response.Content.ReadAsStringAsync().Result)
# let the cmdlet finish it's job
return $responseTask
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment