HTTP request and 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 |
---|---|
| Response content, which can be a string, a TextStreamResponse object, or a JSON object. |
| |
| Response status, for example, 200 or 404. |
| 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 |
| Retrieves the first value of the |
valuesOf |
| Retrieves the array containing all values of the |
ContentType object
The ContentType
data object contains information from the Content-Type response header.
Properties
Property | Description |
---|---|
| The MIME type of the response, for example, text/plain, text/xml, application/json. |
| The string representation of the response charset, for example, utf-8. |
TextStreamResponse object
The TextStreamResponse
interface is used to process a response as a text stream. It lets you implement two methods:
onEachLine(subscriber, onFinish)
, which loops through each line in the stream.onEachMessage(subscriber, onFinish)
, which subscribes to each message sent by the server. This can be used for WebSocket, GRPC, and GraphQL over WebSocket.
Arguments
Argument | Usage in onEachLine | Usage in onEachMessage |
---|---|---|
| Function to process the streamlines. It takes two arguments:
| Function to process the stream messages. It takes three arguments:
|
| Function to be executed after the end of the stream. |
For examples on how to use it, refer to Response handling examples or click Examples in an .http file and select WebSocket Requests or GraphQL Requests.
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 |
---|---|---|
| The request body obtained using one of two methods:
| The request body as a string. For example: client.log(request.body()) |
| Has the | |
| Has two methods:
| |
Each of the elements of the array is a request header with the following methods:
| Each of the elements of the array is a request header with the following methods:
| |
| The HTTP method (such as GET or POST) used in the request. For example: | |
| The request URL obtained using one of two methods:
| The request URL as a string. For example:
client.log(request.url())
|
| Has the |