Skip to content

Commit

Permalink
fix stuff or idk
Browse files Browse the repository at this point in the history
  • Loading branch information
Furrior committed Jan 27, 2025
1 parent f68baec commit d238d48
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum Error {
JsonSerialization(#[from] serde_json::Error),
#[cfg(feature = "http")]
#[error(transparent)]
Request(#[from] Box<ureq::Error>),
Response(#[from] ureq::Transport),
}

impl From<Utf8Error> for Error {
Expand Down
7 changes: 5 additions & 2 deletions src/http.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::{error::Result, jobs};
use serde::{Deserialize, Serialize};
use ureq::OrAnyStatus;
use std::cell::RefCell;
use std::collections::{BTreeMap, HashMap};
use std::io::Write;
use std::time::Duration;

// ----------------------------------------------------------------------------
// Interface
Expand Down Expand Up @@ -95,7 +97,8 @@ fn construct_request(
"head" => client.head(url),
_ => client.get(url),
}
.set("User-Agent", &format!("{PKG_NAME}/{VERSION}"));
.set("User-Agent", &format!("{PKG_NAME}/{VERSION}"))
.timeout(Duration::from_secs(30));

let mut final_body = body.as_bytes().to_vec();

Expand Down Expand Up @@ -138,7 +141,7 @@ fn construct_request(
}

fn submit_request(prep: RequestPrep) -> Result<String> {
let response = prep.req.send_bytes(&prep.body).map_err(Box::new)?;
let response = prep.req.send_bytes(&prep.body).or_any_status()?;

let body;
let mut resp = Response {
Expand Down
7 changes: 7 additions & 0 deletions tests/dm/http.dme
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@
/test/proc/test_400()
var/list/L = execute_request(STATUS400URL)
ASSERT(L["status_code"] == 400)

/test/proc/nonexistent()
try
var/list/L = execute_request("http://nonexistent.nonexistent")
CRASH("Should have failed")
catch
return
1 change: 0 additions & 1 deletion tests/dm/regexp.dme
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ var/expected_error = "Words replace."

/test/proc/crash()
var/output = rustutils_regex_replace(input, pattern, incorrect_pattern_flags, replacement)
world.log << output
ASSERT(output == expected_error)

0 comments on commit d238d48

Please sign in to comment.