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

Commit

Permalink
feat: forward 451 (#35)
Browse files Browse the repository at this point in the history
Forward `451` instead of `ISE`
  • Loading branch information
Daniel-Bloom-dfinity authored May 19, 2022
1 parent c312760 commit 60d00e2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ use futures::{future::OptionFuture, try_join, FutureExt};
use hyper::{
body,
body::Bytes,
http::uri::Parts,
http::{header::CONTENT_TYPE, uri::Parts},
service::{make_service_fn, service_fn},
Body, Client, Request, Response, Server, StatusCode, Uri,
};
use ic_agent::{
agent::http_transport::{reqwest, ReqwestHttpReplicaV2Transport},
agent_error::HttpErrorPayload,
export::Principal,
ic_types::{hash_tree::LookupResult, HashTree},
lookup_value, Agent, AgentError, Certificate,
Expand Down Expand Up @@ -401,6 +402,16 @@ async fn forward_request(
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(format!(r#"Replica Error ({}): "{}""#, reject_code, reject_message).into())
.unwrap())),
Err(AgentError::HttpError(HttpErrorPayload {
status: 451,
content_type,
content,
})) => Err(Ok(content_type
.into_iter()
.fold(Response::builder(), |r, c| r.header(CONTENT_TYPE, c))
.status(451)
.body(content.into())
.unwrap())),
Err(e) => Err(Err(e.into())),
}
}
Expand Down

0 comments on commit 60d00e2

Please sign in to comment.