Extends: Reference
A response object useful to send out responses
var client: StreamPeer
The client currently talking to the server
var server_identifier: String = "GodotTPD"
The server identifier to use on responses [GodotTPD]
var headers: Dictionary
A dictionary of headers
Headers can be set using the set(name, value)
function
var cookies: Array
An array of cookies
Cookies can be set using the cookie(name, value, options)
function
Cookies will be automatically sent via "Set-Cookie" headers to clients
func send_raw(status_code: int, data: PoolByteArray, content_type: String = "application/octet-stream") -> void
Send out a raw (Bytes) response to the client Useful to send files faster or raw data which will be converted by the client
- status: The HTTP status code to send
- data: The body data to send []
- content_type: The type of the content to send ["text/html"]
func send(status_code: int, data: String = "", content_type = "text/html") -> void
Send out a response to the client
- status: The HTTP status code to send
- data: The body data to send []
- content_type: The type of the content to send ["text/html"]
func json(status_code: int, data) -> void
Send out a JSON response to the client
This function will internally call the send()
method
- status_code: The HTTP status code to send
- data: The body data to send, must be a Dictionary or an Array
func set(field: String, value: String) -> void
Sets the response’s header "field" to "value"
- field: the name of the header i.e. "Accept-Type"
- value: the value of this header i.e. "application/json"
func cookie(name: String, value: String, options: Dictionary) -> void
Sets cookie "name" to "value"