diff --git a/paradise-rust-g-patches/0005-Paradise-HTTP-Module-Tweaks.patch b/paradise-rust-g-patches/0005-Paradise-HTTP-Module-Tweaks.patch index 26d68f2..16afcb8 100644 --- a/paradise-rust-g-patches/0005-Paradise-HTTP-Module-Tweaks.patch +++ b/paradise-rust-g-patches/0005-Paradise-HTTP-Module-Tweaks.patch @@ -1,4 +1,4 @@ -From 7df53fb21054bff170a1ecc9d11dcce928f670d6 Mon Sep 17 00:00:00 2001 +From 8a6dadb046618da8cbd32d6651d3e27d36da9d9d Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Thu, 14 Oct 2021 15:50:14 +0100 Subject: [PATCH] Paradise HTTP Module Tweaks @@ -15,7 +15,7 @@ index e74e6d0..ba37ab3 100644 +/proc/rustg_create_async_http_client() return call(RUST_G, "start_http_client")() +/proc/rustg_close_async_http_client() return call(RUST_G, "shutdown_http_client")() diff --git a/src/http.rs b/src/http.rs -index 291e1d1..b02b580 100644 +index 5da2ff1..426f869 100644 --- a/src/http.rs +++ b/src/http.rs @@ -1,8 +1,8 @@ @@ -28,7 +28,7 @@ index 291e1d1..b02b580 100644 // ---------------------------------------------------------------------------- // Interface -@@ -76,7 +76,9 @@ fn setup_http_client() -> reqwest::blocking::Client { +@@ -78,7 +78,9 @@ fn setup_http_client() -> reqwest::blocking::Client { Client::builder().default_headers(headers).build().unwrap() } @@ -39,9 +39,9 @@ index 291e1d1..b02b580 100644 // ---------------------------------------------------------------------------- // Request construction and execution -@@ -93,38 +95,58 @@ fn construct_request( +@@ -95,38 +97,56 @@ fn construct_request( headers: &str, - options: Option<&str>, + options: &str, ) -> Result { - let mut req = match method { - "post" => HTTP_CLIENT.post(url), @@ -60,6 +60,15 @@ index 291e1d1..b02b580 100644 - let headers: BTreeMap<&str, &str> = serde_json::from_str(headers)?; - for (key, value) in headers { - req = req.header(key, value); +- } +- } +- +- let mut output_filename = None; +- if !options.is_empty() { +- let options: RequestOptions = serde_json::from_str(options)?; +- output_filename = options.output_filename; +- if let Some(fname) = options.body_filename { +- req = req.body(std::fs::File::open(fname)?); + HTTP_CLIENT.with(|cell| { + let borrow = cell.borrow_mut(); + match &*borrow { @@ -85,13 +94,11 @@ index 291e1d1..b02b580 100644 + } + + let mut output_filename = None; -+ if let Some(options) = options { -+ if options != "" { -+ let options: RequestOptions = serde_json::from_str(options)?; -+ output_filename = options.output_filename; -+ if let Some(fname) = options.body_filename { -+ req = req.body(std::fs::File::open(fname)?); -+ } ++ if !options.is_empty() { ++ let options: RequestOptions = serde_json::from_str(options)?; ++ output_filename = options.output_filename; ++ if let Some(fname) = options.body_filename { ++ req = req.body(std::fs::File::open(fname)?); + } + } + @@ -114,39 +121,30 @@ index 291e1d1..b02b580 100644 } - } - -- let mut output_filename = None; -- if let Some(options) = options { -- let options: RequestOptions = serde_json::from_str(options)?; -- output_filename = options.output_filename; -- if let Some(fname) = options.body_filename { -- req = req.body(std::fs::File::open(fname)?); -- } -- } -- - Ok(RequestPrep { - req, - output_filename, }) } -@@ -156,3 +178,17 @@ fn submit_request(prep: RequestPrep) -> Result { +@@ -158,3 +178,17 @@ fn submit_request(prep: RequestPrep) -> Result { Ok(serde_json::to_string(&resp)?) } + -+byond_fn! { start_http_client() { ++byond_fn!(fn start_http_client() { + HTTP_CLIENT.with(|cell| { + cell.replace(Some(setup_http_client())) + }); + Some("") -+} } ++}); + -+byond_fn! { shutdown_http_client() { ++byond_fn!(fn shutdown_http_client() { + HTTP_CLIENT.with(|cell| { + cell.replace(None) + }); + Some("") -+} } ++}); diff --git a/src/unzip.rs b/src/unzip.rs index 16b5009..9b5d5c5 100644 --- a/src/unzip.rs diff --git a/paradise-rust-g-patches/0006-Paradise-Fixes-1.patch b/paradise-rust-g-patches/0006-Paradise-Fixes-1.patch deleted file mode 100644 index 3dde14b..0000000 --- a/paradise-rust-g-patches/0006-Paradise-Fixes-1.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0a8cfc9199fc6c8e62a0a9c04b53c51c514c022f Mon Sep 17 00:00:00 2001 -From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> -Date: Sun, 2 Jan 2022 23:06:29 +0000 -Subject: [PATCH] Paradise Fixes 1 - - -diff --git a/dmsrc/redis_pubsub.dm b/dmsrc/redis-pubsub.dm -similarity index 100% -rename from dmsrc/redis_pubsub.dm -rename to dmsrc/redis-pubsub.dm -diff --git a/src/http.rs b/src/http.rs -index b02b580..eecec99 100644 ---- a/src/http.rs -+++ b/src/http.rs -@@ -179,16 +179,16 @@ fn submit_request(prep: RequestPrep) -> Result { - Ok(serde_json::to_string(&resp)?) - } - --byond_fn! { start_http_client() { -+byond_fn!(fn start_http_client() { - HTTP_CLIENT.with(|cell| { - cell.replace(Some(setup_http_client())) - }); - Some("") --} } -+}); - --byond_fn! { shutdown_http_client() { -+byond_fn!(fn shutdown_http_client() { - HTTP_CLIENT.with(|cell| { - cell.replace(None) - }); - Some("") --} } -+}); --- -2.33.0.windows.2 - diff --git a/tg-rust-g b/tg-rust-g index cba5982..b8ee3af 160000 --- a/tg-rust-g +++ b/tg-rust-g @@ -1 +1 @@ -Subproject commit cba59827c6b2ec4a2503b551744f487b3c991803 +Subproject commit b8ee3af967dd00b4508c1b2f4e33c8a2d557a467