PowerShellHttpModule.xml
<?xml version="1.0"?>
<doc> <assembly> <name>PowerShellHttpModule</name> </assembly> <members> <!-- Badly formed XML comment ignored for member "T:PowerShell.REST.DenyHttpResponseCommand" --> <member name="P:PowerShell.REST.DenyHttpResponseCommand.Context"> <summary> <para type="description">The <see cref="T:System.Net.HttpListenerContext"/> that corresponds to the client request.</para> </summary> </member> <member name="T:PowerShell.REST.GetHttpListenerCommand"> <summary> <para type="synopsis">Gets all the created <see cref="T:System.Net.HttpListener"/> objects.</para> <para type="description"> Gets all created <see cref="T:System.Net.HttpListener"/> objects through this module's <see cref="T:System.Management.Automation.Cmdlet"/>s, regardless of if they are still active or not. </para> <example> <para>Submits Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertTo-Json | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Submits Indefinite Responses</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Infinity | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertToJson | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Denies Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json Deny-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> </summary> </member> <member name="T:PowerShell.REST.NewHttpListenerCommand"> <summary> <para type="synopsis">Creates a new <see cref="T:System.Net.HttpListener"/> object.</para> <para type="description"><see cref="T:System.Net.HttpListener"/> objects are used to listen for client requests.</para> <example> <para>Submits Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertTo-Json | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Submits Indefinite Responses</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Infinity | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertToJson | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Denies Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json Deny-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> </summary> </member> <member name="P:PowerShell.REST.NewHttpListenerCommand.UriPrefix"> <summary> <para type="description">URI prefixes that the <see cref="T:System.Net.HttpListener"/> will listen for.</para> <para type="description">This specifies a root URI whereby the <see cref="T:System.Net.HttpListener"/> will respond to any URI under its path.</para> <para type="link" uri="https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistener.prefixes?view=net-5.0#System_Net_HttpListener_Prefixes">Citation.</para> </summary> </member> <member name="P:PowerShell.REST.NewHttpListenerCommand.AuthenticationSchemes"> <summary> <para type="description">Declare how a user can Authenticate.</para> <para type="link" uri="https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistener.authenticationschemes?view=net-5.0#System_Net_HttpListener_AuthenticationSchemes">Citation.</para> </summary> </member> <member name="T:PowerShell.REST.ReceiveHttpRequestCommand"> <summary> <para type="synopsis">Retrieves the body of the <see cref="T:System.Net.HttpListenerRequest"/>.</para> <para type="description"> The body of the <see cref="T:System.Net.HttpListenerRequest"/>, if it is JSON, is expected to be piped to the <code>ConvertFrom-Json</code> <see cref="T:System.Management.Automation.Cmdlet"/>. </para> <example> <para>Submits Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertTo-Json | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Submits Indefinite Responses</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Infinity | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertToJson | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Denies Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json Deny-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> </summary> </member> <member name="P:PowerShell.REST.ReceiveHttpRequestCommand.Context"> <summary> <para type="description">The <see cref="T:System.Net.HttpListenerContext"/> that corresponds to the client request.</para> </summary> </member> <member name="T:PowerShell.REST.StartHttpListenerCommand"> <summary> <para type="synopsis">Starts listening for client requests.</para> <para type="description">Allows this instance to receive incoming requests.</para> <para type="link" uri="https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistener.start?view=net-5.0#System_Net_HttpListener_Start">Citation.</para> <example> <para>Submits Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertTo-Json | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Submits Indefinite Responses</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Infinity | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertToJson | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Denies Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json Deny-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> </summary> </member> <member name="P:PowerShell.REST.StartHttpListenerCommand.Listener"> <summary> <para type="description">Used to listen for client requests.</para> </summary> </member> <member name="T:PowerShell.REST.StopHttpListenerCommand"> <summary> <para type="synopsis">Stops listening for client requests.</para> <para type="description">Causes this instance to stop receiving new incoming requests and terminates processing of all ongoing requests.</para> <para type="link" uri="https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistener.stop?view=net-5.0#System_Net_HttpListener_Stop">Citation.</para> <example> <para>Submits Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertTo-Json | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Submits Indefinite Responses</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Infinity | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertToJson | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Denies Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json Deny-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> </summary> </member> <member name="P:PowerShell.REST.StopHttpListenerCommand.Listener"> <summary> <para type="description">Used to listen for client requests.</para> </summary> </member> <member name="T:PowerShell.REST.SubmitHttpResponseCommand"> <summary> <para type="synopsis">Sends the response to the client and releases the resources held by this <see cref="T:System.Net.HttpListenerResponse"/> instance.</para> <para type="link" uri="https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistenerresponse.close?view=net-5.0#System_Net_HttpListenerResponse_Close">Citation.</para> <para type="description">This should *only* be called once.</para> <example> <para>Submits Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertTo-Json | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Submits Indefinite Responses</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Infinity | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertToJson | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> </summary> </member> <member name="P:PowerShell.REST.SubmitHttpResponseCommand.Json"> <summary> <para type="description">The body for the <see cref="T:System.Net.HttpListenerResponse"/>.</para> <para type="description">This is expected to be piped from the <code>ConvertTo-Json</code> <see cref="T:System.Management.Automation.Cmdlet"/>.</para> </summary> </member> <member name="P:PowerShell.REST.SubmitHttpResponseCommand.Context"> <summary> <para type="description">The <see cref="T:System.Net.HttpListenerContext"/> that corresponds to the client request.</para> </summary> </member> <member name="T:PowerShell.REST.WaitHttpRequestCommand"> <summary> <para type="synopsis">Waits for a client request.</para> <para type="description">This will block while it waits for a client request</para> <para type="link" uri="https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistener.getcontext?view=net-5.0#System_Net_HttpListener_GetContext">Citation.</para> <example> <para>Submits Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertTo-Json | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Submits Indefinite Responses</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Infinity | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json @{Message="Hello $($request.Name)"} | ConvertToJson | Submit-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> <example> <para>Denies Single Response</para> <code> try { 'http://localhost/api' | New-HttpListener -AuthenticationSchemes Basic | Start-HttpListener | Wait-HttpRequest -Count 1 | ForEach-Object { $request = $_ | Receive-HttpRequest | ConvertFrom-Json Deny-HttpResponse -Request $_ } } finally { Get-HttpListener | Stop-HttpListener } </code> <para>Call from *another* shell:</para> <code> $cred = Get-Credential -Message "For PowerShell-REST" -UserName "$ENV:COMPUTERNAME\$ENV:USERNAME" Invoke-RestMethod -Method Post -Uri 'http://localhost/api' -Body $(@{Name='test'} | ConvertTo-Json) -ContentType 'application/json' -Authentication Basic -Credential $cred -AllowUnencryptedAuthentication </code> </example> </summary> </member> <member name="P:PowerShell.REST.WaitHttpRequestCommand.Listener"> <summary> <para type="description">Used to listen for client requests.</para> </summary> </member> <member name="P:PowerShell.REST.WaitHttpRequestCommand.NumberOfRequests"> <summary> <para type="description">Number of requests to listen for before exiting the listener loop.</para> </summary> </member> <member name="P:PowerShell.REST.WaitHttpRequestCommand.InfiniteRequests"> <summary> <para type="description">Never stop the listener loop.</para> <para type="description">WARNING: be careful of how you are using this because it results in an infinite blocking loop.</para> </summary> </member> </members> </doc> |