Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SinonFakeXMLHttpRequest

Index

Properties

async

async: boolean

Whether or not the request is asynchronous.

method

method: string

The request method as a string.

password

password: string

Password, if any.

requestBody

requestBody: string

The request body

requestHeaders

requestHeaders: any

An object of all request headers, i.e.:

responseXML

responseXML: Document

When using respond, this property is populated with a parsed document if response headers indicate as much (see the spec)

status

status: number

The request’s status code. undefined if the request has not been handled (see respond below)

statusText

statusText: string

Only populated if the respond method is called (see below).

upload

url

url: string

The URL set on the request object.

username

username: string

Username, if any.

withCredentials

withCredentials: boolean

Methods

autoRespond

  • autoRespond(ms: number): void
  • Parameters

    • ms: number

    Returns void

error

  • error(): void
  • Simulates a network error on the request. The onerror handler will be called and the status will be 0.

    Returns void

getAllResponseHeaders

  • getAllResponseHeaders(): any
  • All response headers as an object.

    Returns any

getResponseHeader

  • getResponseHeader(header: string): string
  • The value of the given response header, if the request has been responded to (see respond).

    Parameters

    • header: string

    Returns string

onerror

  • onerror(): void
  • Returns void

respond

  • respond(status: number, headers: any, body: string): void
  • Calls the above three methods.

    Parameters

    • status: number
    • headers: any
    • body: string

    Returns void

setResponseBody

  • setResponseBody(body: string): void
  • Sets the respond body, updates the readyState property and fires onreadystatechange. Additionally, populates responseXML with a parsed document if response headers indicate as much.

    Parameters

    • body: string

    Returns void

setResponseHeaders

  • setResponseHeaders(headers: any): void
  • Sets response headers (e.g. { "Content-Type": "text/html", ... }, updates the readyState property and fires onreadystatechange.

    Parameters

    • headers: any

    Returns void