Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dmsrc/http.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
#define rustg_http_request_blocking(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_blocking")(method, url, body, headers, options)
#define rustg_http_request_async(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_async")(method, url, body, headers, options)
#define rustg_http_check_request(req_id) RUSTG_CALL(RUST_G, "http_check_request")(req_id)
/// This is basically just `rustg_http_request_async` if you don't care about the response.
/// This will either return "ok" or an error, as this does not create a job.
#define rustg_http_request_fire_and_forget(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_fire_and_forget")(method, url, body, headers, options)
10 changes: 10 additions & 0 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ byond_fn!(fn http_request_async(method, url, body, headers, options) {
}))
});

byond_fn!(fn http_request_fire_and_forget(method, url, body, headers, options) {
let req = match construct_request(method, url, body, headers, options) {
Ok(r) => r,
Err(e) => return Some(e.to_string())
};

std::thread::spawn(move || req.req.send_bytes(&req.body));
Some("ok".to_owned())
});

// If the response can be deserialized -> success.
// If the response can't be deserialized -> failure or WIP.
byond_fn!(fn http_check_request(id) {
Expand Down