< 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@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
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 11/19/2025 - 17:40:50 Line coverage: 0% (0/3) Total lines: 38 Tag: Kestrun/Kestrun@fcf33342333cef0516fe0d0912a86709874fd026

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()