< 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@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
0%
Covered lines: 0
Uncovered lines: 2
Coverable lines: 2
Total lines: 36
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-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    )
 031    if ($null -ne $Context.Response) {
 32        # Call the C# method on the $Context.Response object
 033        $Context.Response.WriteBinaryResponse($InputObject, $StatusCode, $ContentType)
 34    }
 35}
 36

Methods/Properties

Write-KrBinaryResponse()