JetBrains Rider 2022.3 Help

HTTP Response reference

Response properties

The response object holds the information about a received HTTP Response (response content, headers, status, and so on) and provides access to the headers and contentType nested objects.

Property

Description

body (string | LineStreamResponse | object)

Response content, which can be a string, a LineStreamResponse object, or a JSON object.

headers (ResponseHeaders)

The response headers storage object.

status (int)

Response status, for example, 200 or 404.

contentType (ContentType)

The contentType object, which holds the data on the Content-Type response header value.

Headers object

The ResponseHeaders object is used for retrieving the data about response headers' values.

Methods

Method

Parameters

Description

valueOf

headerName (string)

Retrieves the first value of the headerName response header or null if the headerName response header does not exist.

valuesOf

headerName (string)

Retrieves the array containing all values of the headerName response header. Returns an empty array if the headerName response header does not exist.

ContentType object

The ContentType data object contains information from the Content-Type response header.

Properties

Property

Description

mimeType (string)

The MIME type of the response, for example, text/plain, text/xml, application/json.

charset (string)

The string representation of the response charset, for example, utf-8.

LineStreamResponse object

The LineStreamResponse interface is used to process a response as a stream of lines. It implements a onEachLine(line, unsubscribe) method, which loops through each line in the stream, one after the other. The method takes two arguments:

Arguments

Argument

Description

line (a string or a JSON object)

A line (event) received as part of the stream.

unsubscribe

Function to terminate execution of the onEachLine block.

Request properties

The request object holds the information about the HTTP request and can be used both in pre-request scripts and in response handler scripts.

Property

When used in pre-request scripts

When used in response handler scripts

body

The request body obtained using one of two methods:

  • getRaw(): returns the request body in the raw format: If the request body contains variables, their names are displayed instead of their values.

  • tryGetSubstituted(): returns the request body with all known variables replaced with their values.

The request body as a string, for example client.log(request.body()).

environment

Has the get(name) method, which retrieves a value of the environment variable identified by its name or returns null if it does not exist.

headers

Has two methods:

  • all: returns the array containing the values of all headers of the current request.

  • findByName(name): retrieves the value of the header identified by the name parameter.

Each of the elements of the array is a request header with the following methods:

  • name: the header name, such as Content-Type.

  • getRawValue: returns the header value in the raw format: If the header contains variables, their names are displayed instead of their values.

  • tryGetSubstitutedValue(): returns the header with all known variables replaced with their values.

Each of the elements of the array is a request header with the following methods:

  • name: the header name, such as Content-Type.

  • value(): the header value, such as application/json.

url

The request URL obtained using one of two methods:

  • getRaw(): returns the request URL in the raw format: If the URL contains variables, their names are displayed instead of their values.

  • tryGetSubstituted(): returns the request URL with all known variables replaced with their values.

The request URL as a string.

variables

Has the get(name) method, which retrieves a value of the per-request variable identified by its name or returns null if it does not exist.

Last modified: 11 January 2023