sendHTTPRequest

Wraps sendHTTPRequestImpl by proxying calls to it via the persistentQuerier subthread.

Once the query returns, the response body is checked to see whether or not an error occurred. If so, it throws an exception with a descriptive message.

Note: Must be called from inside a Fiber.

version(TwitchSupport && WithTwitchPlugin)
package
sendHTTPRequest
(,
const string url
,
const string caller = __FUNCTION__
,
const string authorisationHeader = string.init
,,
ubyte[] body_ = null
,
const string contentType = string.init
,
int id = 0
,
const bool recursing = false
)

Parameters

plugin TwitchPlugin

The current TwitchPlugin.

url string

The URL to query.

caller string

Name of the calling function.

authorisationHeader string

Authorisation HTTP header to pass.

verb HTTPVerb

What HTTPVerb to use in the request.

body_ ubyte[]

Request body to send in case of verbs like POST and PATCH.

contentType string

"Content-Type" HTTP header to pass.

id int

Numerical ID to use instead of generating a new one.

recursing bool

Whether or not this is a recursive call and another one should not be attempted.

Return Value

The QueryResponse that was discovered while monitoring the TwitchPlugin.responseBucket

as having been received from the server.

Throws

EmptyResponseException if the response body was empty. ErrorJSONException if the response body was JSON but contained an "error" key. TwitchQueryException if there were other unrecoverable errors.

Examples

immutable response = sendHTTPRequest(
    plugin,
    "https://id.twitch.tv/oauth2/validate",
    __FUNCTION__,
    "OAuth 30letteroauthstring");