HTTP Request
Holder datum for ingame HTTP requests
Holds information regarding to methods used, URL, and response, as well as job IDs and progress tracking for async requests
Vars | |
_raw_response | The raw response, which will be decoeded into a /datum/http_response |
---|---|
body | Body of the request being sent |
cb | Callback for executing after async requests. Will be called with an argument of /datum/http_response as first argument |
headers | Request headers being sent |
id | The ID of the request (Only set if it is an async request) |
in_progress | Is the request in progress? (Only set if it is an async request) |
method | HTTP method used |
output_file | If present, response body will be saved to this file. |
url | URL that the request is being sent to |
Procs | |
begin_async | Async execution starter |
build_options | Options builder |
execute_blocking | Blocking executor |
into_response | Response deserializer |
is_complete | Async completion checker |
prepare | Preparation handler |
Var Details
_raw_response
The raw response, which will be decoeded into a /datum/http_response
body
Body of the request being sent
cb
Callback for executing after async requests. Will be called with an argument of /datum/http_response as first argument
headers
Request headers being sent
id
The ID of the request (Only set if it is an async request)
in_progress
Is the request in progress? (Only set if it is an async request)
method
HTTP method used
output_file
If present, response body will be saved to this file.
url
URL that the request is being sent to
Proc Details
begin_async
Async execution starter
Tells the request to start executing inside its own thread inside RUSTG Preferred over blocking, but also requires SShttp to be active As such, you cannot use this for events which may happen at roundstart (EG: IPIntel, BYOND account tracking, etc)
build_options
Options builder
Builds options for if we want to download files with SShttp
execute_blocking
Blocking executor
Remains as a proof of concept to show it works, but should NEVER be used to do FFI halting the entire DD process up Async rqeuests are much preferred, but also require the subsystem to be firing for them to be answered
into_response
Response deserializer
Takes a HTTP request object, and converts it into a /datum/http_response The entire thing is wrapped in try/catch to ensure it doesnt break on invalid requests Can be called on async and blocking requests
is_complete
Async completion checker
Checks if an async request has been complete Has safety checks built in to compensate if you call this on blocking requests, or async requests which have already finished
prepare
Preparation handler
Call this with relevant parameters to form the request you want to make
Arguments:
- _method - HTTP Method to use, see code/__DEFINES/rust_g.dm for a full list
- _url - The URL to send the request to
- _body - The body of the request, if applicable
- _headers - Associative list of HTTP headers to send, if applicab;e