Skip to main content

PHPResponse

PHP response. Body is an ArrayBuffer because it can contain binary data.

This type is used in Comlink.transferHandlers.set(‘PHPResponse’, { … }) so be sure to update that if you change this type.

Implements

Index

Constructors

constructor

  • new PHPResponse(httpStatusCode: number, headers: Record<string, string[]>, body: ArrayBuffer, errors?: string, exitCode?: number): PHPResponse
  • Parameters

    • httpStatusCode: number
    • headers: Record<string, string[]>
    • body: ArrayBuffer
    • errors: string = ''
    • exitCode: number = 0

    Returns PHPResponse

Properties

readonlybytes

bytes: ArrayBuffer

Response body. Contains the output from echo, print, inline HTML etc.

readonlyerrors

errors: string

Stderr contents, if any.

readonlyexitCode

exitCode: number

The exit code of the script. 0 is a success, while 1 and 2 indicate an error.

readonlyheaders

headers: Record<string, string[]>

Response headers.

readonlyhttpStatusCode

httpStatusCode: number

Response HTTP status code, e.g. 200.

Accessors

json

  • get json(): any
  • Response body as JSON.


    Returns any

text

  • get text(): string
  • Response body as text.


    Returns string

Methods

toRawData

staticforHttpCode

  • forHttpCode(httpStatusCode: number, text?: string): PHPResponse
  • Parameters

    • httpStatusCode: number
    • text: string = ''

    Returns PHPResponse

staticfromRawData