HttpClient

Wrapper around the client's request aand response.

final
static if(isWeb)
class HttpClient {}

Constructors

this
this(HTTPServerRequest request, HTTPServerResponse response)

Createsa new http client.

Members

Functions

addContext
void addContext(string name, T value)

Adds a generic context value to the client.

error
void error(HttpStatus status)

Throws a http status exception.

forbidden
void forbidden()

Sends a forbidden error

getBody
ubyte[] getBody()

Gets the body data from the response stream.

getContext
T getContext(string name, T defaultValue)

Gets a value from the client's context.

getModelFromJson
T getModelFromJson(CTORARGS args)

Gets a model from the request's json.

getSanitizedModelFromJson
T getSanitizedModelFromJson(CTORARGS args)

Gets a santized model from the request's json.

hasContext
bool hasContext(string name)

Checks whether a value is present n the client's context or not.

internalRedirect
void internalRedirect(string path)

Does an internal redirect.

login
void login(long loginTime, Role role)

Logs the client in.

logout
void logout()

Logs the client out.

notFound
void notFound()

Sends a 404 status.

redirect
void redirect(string url, HttpStatus status)

Redirects the client.

unauthorized
void unauthorized()

Sends an unauthorized error

write
void write(string data)

Writes data to the response stream.

write
void write(ubyte[] data)

Writes data to the response stream.

Properties

clientAddress
auto clientAddress [@property getter]

Gets the raw client address of the request.

clientCertificate
auto clientCertificate [@property getter]

Gets the client certificate from the request.

connected
bool connected [@property getter]

Gets a boolean determnining whether the response is connected or not.

contentType
string contentType [@property getter]

Gets the content type from the request.

contentTypeParameters
string contentTypeParameters [@property getter]

Gets the content type parameters from the request.

cookieConsent
HttpCookieConsent cookieConsent [@property getter]

Gets the cookie consent of a user.

cookieConsent
HttpCookieConsent cookieConsent [@property setter]

Sets the cookie consent of a user.

cookies
HttpCookies cookies [@property getter]

Gets the cookies.

files
auto files [@property getter]

Gets the files from the request.

forceApi
bool forceApi [@property setter]

Sets a boolean determining whether the request should be forced as an api request or not.

forceApi
bool forceApi [@property getter]

Gets a boolean determining whether the request should be forced as an api request or not.

form
auto form [@property getter]

Gets the form from the request.

fullUrl
auto fullUrl [@property getter]

Gets the full url from the request.

handlingRequest
bool handlingRequest [@property setter]

Sets a boolean determining whether the client is handling the request or not.

headers
auto headers [@property getter]

Gets the headers from the request.

host
string host [@property getter]

Gets the host from the request.

httpParams
auto httpParams [@property getter]

Gets the generic http parameters.

ipAddress
string ipAddress [@property getter]

Gets the ip address.

isLastRoute
bool isLastRoute [@property getter]

Gets a boolean determining whether it's the client's last route to handle.

isLastRoute
bool isLastRoute [@property setter]

Sets a boolean determining whether it's the client's last route to handle.

json
auto json [@property getter]

Gets the json from the request.

language
string language [@property getter]

Gets the language of the client.

language
string language [@property setter]

Sets the language of the client.

method
HttpMethod method [@property getter]

Gets the method.

path
string path [@property getter]

Gets the current path.

path
string path [@property setter]

Sets the path of the client.

privacy
PrivacyCollection privacy [@property getter]

Gets the privacy collection of the client.

query
auto query [@property getter]

Gets a mapped query of the query string.

queryString
string queryString [@property getter]

Gets the query string.

rawRequest
HTTPServerRequest rawRequest [@property getter]

Gets the raw vibe.d request.

rawResponse
HTTPServerResponse rawResponse [@property getter]

Gets the raw vibe.d response.

redirected
bool redirected [@property getter]

Boolean determining whether the client has been redirected or not.

requestStream
auto requestStream [@property getter]

Gets the raw request stream.

responseStream
auto responseStream [@property getter]

Gets the raw response stream.

role
Role role [@property getter]

Gets the role associated with the client.

route
Route route [@property getter]

Gets the route.

route
Route route [@property setter]

Sets the route.

session
HttpSession session [@property getter]

Gets the session.

statusCode
HttpStatus statusCode [@property getter]

Gets the status code of the response.

tls
bool tls [@property getter]

Gets a boolean determnining whether the request was done over a secure tls protocol.

Meta