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
| Name | Type | Description |
|---|
path | string | The request path, e.g. "/users/42". Read-only. |
body | string | The raw request body. Read-only. |
remote_addr | string | The client IP (after proxy header rewriting when configured). Read-only. |
remote_port | integer | The remote port the request came from. Read-only. |
local_addr | string | The local address that accepted the connection. Read-only. |
local_port | integer | The local port that accepted the connection. Read-only. |
method | string | The HTTP method, e.g. "GET" or "POST". Read-only. |
content_length | integer | The request Content-Length. Read-only. |
authorization_count | integer | The number of Authorization credentials parsed from the request. Read-only. |
client | holylib.CBaseClient | nil | The HolyLib CBaseClient for the connected player that matched this request's IP, if any. Read-only. |
player | garrysmod.Player | nil | The Player for the connected player that matched this request's IP, if any. Read-only. |
Methods
finish | Sends the response and invalidates the request and its response. |
getHeader | Returns the value of the given header, or nil if missing. |
getParam | Returns the value of the given query / form parameter, or nil if missing. |
getPathParam | Returns a path parameter captured from a :name segment in the route pattern, or nil if missing. |
hasHeader | Returns true if the request has the given header. |
hasParam | Returns true if the request has the given query / form parameter. |
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.
function http.Server.Request:getParam(key: string): string | nil
Returns the value of the given query / form parameter, or nil if missing.
Parameters
| Name | Type | Description |
|---|
key | string | The parameter name. |
Returns
| Type | Name | Description |
|---|
string | nil | value | |
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
| Name | Type | Description |
|---|
key | string | The path parameter name without the leading ":". |
Returns
| Type | Name | Description |
|---|
string | nil | value | |
function http.Server.Request:hasParam(key: string): boolean
Returns true if the request has the given query / form parameter.
Parameters
| Name | Type | Description |
|---|
key | string | The parameter name. |
Returns
| Type | Name | Description |
|---|
boolean | has_param | |