Created
July 18, 2016 10:18
-
-
Save stefanschneider/072f6b88345a2d9c3269b0b957553f76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!$env:HOST ) { $env:HOST = "127.0.0.1" } | |
if (!$env:PORT ) { $env:PORT = "8089" } | |
$listener = New-Object System.Net.HttpListener | |
$listener.Prefixes.Add("http://${env:HOST}:${env:PORT}/") | |
$listener.Start() | |
Write-Host "Listening at $($listener.Prefixes[0]) ..." | |
while ($listener.IsListening) | |
{ | |
$context = $listener.GetContext() | |
$requestUrl = $context.Request.Url | |
$response = $context.Response | |
Write-Output "> $requestUrl" | |
$localPath = $requestUrl.LocalPath | |
$buffer = [System.Text.Encoding]::UTF8.GetBytes(((gci -path env:*) | Out-String)) | |
$response.ContentLength64 = $buffer.Length | |
$response.OutputStream.Write($buffer, 0, $buffer.Length) | |
Write-Output "< $($response.StatusCode)" | |
$response.Dispose() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: https://raw.githubusercontent.com/hpcloud/cf-exe-buildpack/master/sample-app/httpl.ps1