Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
fix: correctly check headers parse result (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arqu authored Sep 6, 2022
1 parent 7b2f9a7 commit 82a1b82
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions iroh-gateway/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,17 @@ pub async fn get_handler(
// init headers
format.write_headers(&mut headers);
add_user_headers(&mut headers, state.config.user_headers().clone());
headers.insert(
&HEADER_X_IPFS_PATH,
HeaderValue::from_str(&full_content_path).unwrap(),
);
let hv = match HeaderValue::from_str(&full_content_path) {
Ok(hv) => hv,
Err(err) => {
return Err(error(
StatusCode::BAD_REQUEST,
&format!("invalid header: {}", err),
&state,
));
}
};
headers.insert(&HEADER_X_IPFS_PATH, hv);

// handle request and fetch data
let req = Request {
Expand Down

0 comments on commit 82a1b82

Please sign in to comment.