HeadRequest
The HTTP HEAD method requests the headers that are returned if the specified resource would be requested with an HTTP GET method. Such a request can be done before deciding to download a large resource to save bandwidth, for example.
Extends:
Examples:
import { Actor } from '@serenity-js/core';
import { CallAnApi, HeadRequest, LastResponse, Send } from '@serenity-js/rest'
import { Ensure, equals } from '@serenity-js/assertions';
const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
actor.attemptsTo(
Send.a(HeadRequest.to('/downloads/my-test-document.pdf')),
Ensure.that(LastResponse.status(), equals(200)),
Ensure.that(LastResponse.header('Content-Length'), equals(256)), // assuming we know the size of the document
);
Tests:
Static Method Summary
Static Public Methods | ||
public static |
to(resourceUri: Answerable<string>): HeadRequest Configures the object with a destination URI. |
Method Summary
Public Methods | ||
public |
using(config: Answerable<AxiosRequestConfig>): HeadRequest |
Inherited Summary
From class HTTPRequest | ||
public |
subject: string |
|
public |
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<AxiosRequestConfig> |
Static Public Methods
public static to(resourceUri: Answerable<string>): HeadRequest source
Configures the object with a destination URI.
When the resourceUri
is not a fully qualified URL but a path, such as /products/2
,
it gets concatenated with the URL provided to the Axios instance
when the CallAnApi Ability was instantiated.
Params:
Name | Type | Attribute | Description |
resourceUri | Answerable<string> | The URI where the Actor should send the HTTPRequest. |
Public Methods
public using(config: Answerable<AxiosRequestConfig>): HeadRequest source
Params:
Name | Type | Attribute | Description |
config | Answerable<AxiosRequestConfig> | Axios request configuration overrides |