< Summary - Kestrun — Combined Coverage

Information
Class: Public.Response.Write-KrStreamResponse
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Response/Write-KrStreamResponse.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
0%
Covered lines: 0
Uncovered lines: 2
Coverable lines: 2
Total lines: 35
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Response/Write-KrStreamResponse.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Writes a stream directly to the HTTP response body.
 4    .DESCRIPTION
 5        Copies the provided stream to the response output stream. Useful for
 6        forwarding large files or custom streaming scenarios.
 7    .PARAMETER InputObject
 8        The stream to write to the response body. This should be a valid stream object.
 9    .PARAMETER StatusCode
 10        The HTTP status code to set for the response. Defaults to 200 (OK).
 11    .PARAMETER ContentType
 12        The content type of the response. If not specified, defaults to "application/octet-stream".
 13    .EXAMPLE
 14        Write-KrStreamResponse -InputObject $myStream -StatusCode 200 -ContentType "application/octet-stream"
 15        Writes the $myStream to the response body with a 200 OK status code and content type "application/octet-stream".
 16    .NOTES
 17        This function is designed to be used in the context of a Kestrun server response.
 18#>
 19function Write-KrStreamResponse {
 20    [KestrunRuntimeApi('Route')]
 21    [CmdletBinding()]
 22    param(
 23        [Parameter(Mandatory = $true)]
 24        [System.IO.Stream]$InputObject,
 25        [Parameter()]
 26        [int]$StatusCode = 200,
 27        [Parameter()]
 28        [string]$ContentType
 29    )
 030    if ($null -ne $Context.Response) {
 31        # Call the C# method on the $Context.Response object
 032        $Context.Response.WriteStreamResponse($InputObject, $StatusCode, $ContentType)
 33    }
 34}
 35

Methods/Properties

Write-KrStreamResponse()