HttpTrait
Discord HTTP client.
Tags
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
PromiseInterfaceget()
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
PromiseInterfacegetDriver()
Gets the HTTP driver, so another client can share it.
public
getDriver() : DriverInterface|null
Return values
DriverInterface|nullgetUserAgent()
Returns the User-Agent of the HTTP client.
public
getUserAgent() : string
Return values
stringhandleError()
Returns an exception based on the request.
public
handleError(ResponseInterface $response) : Throwable
Parameters
- $response : ResponseInterface
Return values
ThrowableisUnboundEndpoint()
Checks if the request is for an endpoint not bound by the global rate limit.
public
static isUnboundEndpoint(Request $request) : bool
Parameters
- $request : Request
Tags
Return values
boolpatch()
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
PromiseInterfacepost()
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
PromiseInterfaceput()
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
PromiseInterfacequeueRequest()
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
PromiseInterfacesetDriver()
Sets the driver of the HTTP client.
public
setDriver(DriverInterface $driver) : void
Parameters
- $driver : DriverInterface
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
PromiseInterfacegetBucket()
Gets a bucket.
protected
getBucket(string $key) : Bucket
Parameters
- $key : string
Return values
BucketguessContent()
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