< Summary - Kestrun — Combined Coverage

Information
Class: Public.Response.Write-KrBinaryResponse
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Response/Write-KrBinaryResponse.ps1
Tag: Kestrun/Kestrun@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 39
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: 39 Tag: Kestrun/Kestrun@fcf33342333cef0516fe0d0912a86709874fd026

Metrics

File(s)

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

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Writes binary data directly to the HTTP response body.
 4    .DESCRIPTION
 5        Sends a byte array to the client. Useful for returning images or other
 6        binary content with a specified status code and content type.
 7    .PARAMETER InputObject
 8        The binary data to write to the response body. This should be a byte array.
 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-KrBinaryResponse -InputObject $myBinaryData -StatusCode 200 -ContentType "application/octet-stream"
 15        Writes the $myBinaryData to the response body with a 200 OK status code and
 16        content type "application/octet-stream".
 17    .NOTES
 18        This function is designed to be used in the context of a Kestrun server response.
 19#>
 20function Write-KrBinaryResponse {
 21    [KestrunRuntimeApi('Route')]
 22    [CmdletBinding()]
 23    param(
 24        [Parameter(Mandatory = $true)]
 25        [byte[]]$InputObject,
 26        [Parameter()]
 27        [int]$StatusCode = 200,
 28        [Parameter()]
 29        [string]$ContentType
 30    )
 31    # Only works inside a route script block where $Context is available
 032    if ($null -ne $Context.Response) {
 33        # Call the C# method on the $Context.Response object
 034        $Context.Response.WriteBinaryResponse($InputObject, $StatusCode, $ContentType)
 35    } else {
 036        Write-KrOutsideRouteWarning
 37    }
 38}
 39

Methods/Properties

Write-KrBinaryResponse()