< 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@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 38
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 08/26/2025 - 01:25:22 Line coverage: 0% (0/2) Total lines: 34 Tag: Kestrun/Kestrun@07f821172e5dc3657f1be7e6818f18d6721cf38a09/04/2025 - 22:37:32 Line coverage: 0% (0/2) Total lines: 35 Tag: Kestrun/Kestrun@afb7aadc0a8a42bfa2b51ea62c8a6e2cf63faec609/12/2025 - 03:43:11 Line coverage: 0% (0/3) Total lines: 38 Tag: Kestrun/Kestrun@d160286e3020330b1eb862d66a37db2e26fc9042

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    )
 30    # Only works inside a route script block where $Context is available
 031    if ($null -ne $Context.Response) {
 32        # Call the C# method on the $Context.Response object
 033        $Context.Response.WriteStreamResponse($InputObject, $StatusCode, $ContentType)
 34    } else {
 035        Write-KrOutsideRouteWarning
 36    }
 37}
 38

Methods/Properties

Write-KrStreamResponse()