Skip to content

Commit

Permalink
feat: add content-length on POST
Browse files Browse the repository at this point in the history
Not all embedded devices are acceptable to receiving unspecified amounts
of data. Appending the content-length up front helps this devices
succeed.
  • Loading branch information
lyager committed Feb 29, 2024
1 parent 43457a3 commit abc5f42
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugins/upload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ async fn upload<R: Runtime>(
) -> Result<String> {
// Read the file
let file = File::open(file_path).await?;
let file_len = file.metadata().await.unwrap().len();

// Create the request and attach the file to the body
let client = reqwest::Client::new();
let mut request = client.post(url).body(file_to_body(id, window, file));
let mut request = client
.post(url)
.header(reqwest::header::CONTENT_LENGTH, file_len)
.body(file_to_body(id, window, file));

// Loop trought the headers keys and values
// and add them to the request object.
Expand Down

0 comments on commit abc5f42

Please sign in to comment.