< 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@2d87023b37eb91155071c91dd3d6a2eeb3004705
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 08/26/2025 - 01:25:22 Line coverage: 0% (0/2) Total lines: 35 Tag: Kestrun/Kestrun@07f821172e5dc3657f1be7e6818f18d6721cf38a09/04/2025 - 18:11:31 Line coverage: 0% (0/2) Total lines: 36 Tag: Kestrun/Kestrun@de99e24698289f3f61ac7b73e96092732ae12b0509/12/2025 - 03:43:11 Line coverage: 0% (0/3) Total lines: 39 Tag: Kestrun/Kestrun@d160286e3020330b1eb862d66a37db2e26fc9042

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