diff --git a/Cargo.lock b/Cargo.lock index f995f14..089b72d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1521,7 +1521,7 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "sign-firmware" -version = "0.1.5" +version = "0.1.6" dependencies = [ "anyhow", "async-io", diff --git a/Cargo.toml b/Cargo.toml index 532da5d..c0915c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sign-firmware" -version = "0.1.5" +version = "0.1.6" authors = ["Jack Hogan "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/src/net.rs b/src/net.rs index 023848a..54310f5 100644 --- a/src/net.rs +++ b/src/net.rs @@ -47,7 +47,7 @@ pub async fn generate_tls(url: &str) -> anyhow::Result Ok(tls) } -pub fn create_raw_request(request: http::Request) -> String { +pub fn create_raw_request_no_body(request: &http::Request) -> String { let method = request.method(); let uri = request.uri(); let headers = request.headers(); @@ -61,6 +61,14 @@ pub fn create_raw_request(request: http::Request) -> String { request_text } +pub fn create_raw_request(request: &http::Request) -> String { + let mut text = create_raw_request_no_body(request); + + text.push_str(&request.body().to_string()); + + text +} + pub async fn handle_redirect(url: &str) -> anyhow::Result> { let request = Request::builder() .method("GET") @@ -72,7 +80,7 @@ pub async fn handle_redirect(url: &str) -> anyhow::Result anyhow::Result anyhow::Result<()> { let mut tls = generate_tls(url).await?; - let request_text = create_raw_request(request); + let request_text = create_raw_request_no_body(&request); tls.write_all(request_text.as_bytes()) .await diff --git a/src/printer.rs b/src/printer.rs index 52db6c5..17ff7f3 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -77,7 +77,7 @@ pub async fn post_event(event: PrinterEvent) -> anyhow::Result<()> { .body(serde_json::to_string(&event.message())?) .unwrap(); - let request_text = create_raw_request(request); + let request_text = create_raw_request(&request); tls.write_all(request_text.as_bytes()) .await