dreamworkAPI
Ctrl K
GitHub
classDocs / http / Server / Request

http.Server.Request

classserversource
Object → http.Server.Request

An incoming request delivered to an http.Server route handler.

A request is valid until it is finished, synchronous handlers finish when they return. Properties read before that stay readable, everything else raises an error.

Constructor

http.Server.Request(exchange: http.Server.Exchange): http.Server.Request

Fields

NameTypeDescription
pathstringThe request path, e.g. "/users/42". Read-only.
bodystringThe raw request body. Read-only.
remote_addrstringThe client IP (after proxy header rewriting when configured). Read-only.
remote_portintegerThe remote port the request came from. Read-only.
local_addrstringThe local address that accepted the connection. Read-only.
local_portintegerThe local port that accepted the connection. Read-only.
methodstringThe HTTP method, e.g. "GET" or "POST". Read-only.
content_lengthintegerThe request Content-Length. Read-only.
authorization_countintegerThe number of Authorization credentials parsed from the request. Read-only.
clientholylib.CBaseClient | nilThe HolyLib CBaseClient for the connected player that matched this request's IP, if any. Read-only.
playergarrysmod.Player | nilThe Player for the connected player that matched this request's IP, if any. Read-only.

Methods

finishSends the response and invalidates the request and its response.
getHeaderReturns the value of the given header, or nil if missing.
getParamReturns the value of the given query / form parameter, or nil if missing.
getPathParamReturns a path parameter captured from a :name segment in the route pattern, or nil if missing.
hasHeaderReturns true if the request has the given header.
hasParamReturns true if the request has the given query / form parameter.

#Request:finish

serversource
function http.Server.Request:finish()

Sends the response and invalidates the request and its response.

Synchronous handlers are finished automatically when they return, call this only from handlers that returned false to defer the reply.

Calling it again does nothing.

#Request:getHeader

servernodiscardsource
function http.Server.Request:getHeader(key: string): string | nil

Returns the value of the given header, or nil if missing.

Parameters
NameTypeDescription
keystringThe header name.
Returns
TypeNameDescription
string | nilvalue

#Request:getParam

servernodiscardsource
function http.Server.Request:getParam(key: string): string | nil

Returns the value of the given query / form parameter, or nil if missing.

Parameters
NameTypeDescription
keystringThe parameter name.
Returns
TypeNameDescription
string | nilvalue

#Request:getPathParam

servernodiscardsource
function http.Server.Request:getPathParam(key: string): string | nil

Returns a path parameter captured from a :name segment in the route pattern, or nil if missing.

Parameters
NameTypeDescription
keystringThe path parameter name without the leading ":".
Returns
TypeNameDescription
string | nilvalue

#Request:hasHeader

servernodiscardsource
function http.Server.Request:hasHeader(key: string): boolean

Returns true if the request has the given header.

Parameters
NameTypeDescription
keystringThe header name.
Returns
TypeNameDescription
booleanhas_header

#Request:hasParam

servernodiscardsource
function http.Server.Request:hasParam(key: string): boolean

Returns true if the request has the given query / form parameter.

Parameters
NameTypeDescription
keystringThe parameter name.
Returns
TypeNameDescription
booleanhas_param
Generated from the dreamwork meta branch.