DiscordPHP-Http Documentation

HttpTrait

Discord HTTP client.

Tags
author

David Cole david.cole1340@gmail.com

Table of Contents

Methods

delete()  : PromiseInterface
Runs a DELETE request.
get()  : PromiseInterface
Runs a GET request.
getDriver()  : DriverInterface|null
Gets the HTTP driver, so another client can share it.
getUserAgent()  : string
Returns the User-Agent of the HTTP client.
handleError()  : Throwable
Returns an exception based on the request.
isUnboundEndpoint()  : bool
Checks if the request is for an endpoint not bound by the global rate limit.
patch()  : PromiseInterface
Runs a PATCH request.
post()  : PromiseInterface
Runs a POST request.
put()  : PromiseInterface
Runs a PUT request.
queueRequest()  : PromiseInterface
Builds and queues a request.
setDriver()  : void
Sets the driver of the HTTP client.
checkQueue()  : void
Checks the request queue to see if more requests can be sent out.
checkunboundQueue()  : void
Checks the interaction queue to see if more requests can be sent out.
executeRequest()  : PromiseInterface
Executes a request.
getBucket()  : Bucket
Gets a bucket.
guessContent()  : mixed
Guesses the headers and transforms the content of a request.
sortIntoBucket()  : void
Sorts a request into a bucket.

Methods

delete()

Runs a DELETE request.

public delete(string|Endpoint $url[, mixed $content = null ][, array<string|int, mixed> $headers = [] ]) : PromiseInterface
Parameters
$url : string|Endpoint
$content : mixed = null
$headers : array<string|int, mixed> = []
Return values
PromiseInterface

get()

Runs a GET request.

public get(string|Endpoint $url[, mixed $content = null ][, array<string|int, mixed> $headers = [] ]) : PromiseInterface
Parameters
$url : string|Endpoint
$content : mixed = null
$headers : array<string|int, mixed> = []
Return values
PromiseInterface

getUserAgent()

Returns the User-Agent of the HTTP client.

public getUserAgent() : string
Return values
string

handleError()

Returns an exception based on the request.

public handleError(ResponseInterface $response) : Throwable
Parameters
$response : ResponseInterface
Return values
Throwable

patch()

Runs a PATCH request.

public patch(string|Endpoint $url[, mixed $content = null ][, array<string|int, mixed> $headers = [] ]) : PromiseInterface
Parameters
$url : string|Endpoint
$content : mixed = null
$headers : array<string|int, mixed> = []
Return values
PromiseInterface

post()

Runs a POST request.

public post(string|Endpoint $url[, mixed $content = null ][, array<string|int, mixed> $headers = [] ]) : PromiseInterface
Parameters
$url : string|Endpoint
$content : mixed = null
$headers : array<string|int, mixed> = []
Return values
PromiseInterface

put()

Runs a PUT request.

public put(string|Endpoint $url[, mixed $content = null ][, array<string|int, mixed> $headers = [] ]) : PromiseInterface
Parameters
$url : string|Endpoint
$content : mixed = null
$headers : array<string|int, mixed> = []
Return values
PromiseInterface

queueRequest()

Builds and queues a request.

public queueRequest(string $method, Endpoint $url, mixed $content[, array<string|int, mixed> $headers = [] ]) : PromiseInterface
Parameters
$method : string
$url : Endpoint
$content : mixed
$headers : array<string|int, mixed> = []
Return values
PromiseInterface

checkQueue()

Checks the request queue to see if more requests can be sent out.

protected checkQueue([bool $check_interactions = true ]) : void
Parameters
$check_interactions : bool = true

checkunboundQueue()

Checks the interaction queue to see if more requests can be sent out.

protected checkunboundQueue() : void

executeRequest()

Executes a request.

protected executeRequest(Request $request[, Deferred|null $deferred = null ]) : PromiseInterface
Parameters
$request : Request
$deferred : Deferred|null = null
Return values
PromiseInterface

getBucket()

Gets a bucket.

protected getBucket(string $key) : Bucket
Parameters
$key : string
Return values
Bucket

guessContent()

Guesses the headers and transforms the content of a request.

protected guessContent(mixed &$content) : mixed
Parameters
$content : mixed

sortIntoBucket()

Sorts a request into a bucket.

protected sortIntoBucket(Request $request) : void
Parameters
$request : Request
On this page

Search results