mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
add content-type octet stream helper fn (#5062)
This commit is contained in:
@@ -3,13 +3,12 @@ use crate::{
|
||||
version::{
|
||||
add_consensus_block_value_header, add_consensus_version_header,
|
||||
add_execution_payload_blinded_header, add_execution_payload_value_header,
|
||||
fork_versioned_response, inconsistent_fork_rejection,
|
||||
add_ssz_content_type_header, fork_versioned_response, inconsistent_fork_rejection,
|
||||
},
|
||||
};
|
||||
use beacon_chain::{
|
||||
BeaconBlockResponseWrapper, BeaconChain, BeaconChainTypes, ProduceBlockVerification,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use eth2::types::{
|
||||
self as api_types, EndpointVersion, ProduceBlockV3Metadata, SkipRandaoVerification,
|
||||
};
|
||||
@@ -95,8 +94,8 @@ pub fn build_response_v3<T: BeaconChainTypes>(
|
||||
match accept_header {
|
||||
Some(api_types::Accept::Ssz) => Response::builder()
|
||||
.status(200)
|
||||
.header("Content-Type", "application/ssz")
|
||||
.body(block_contents.as_ssz_bytes().into())
|
||||
.map(|res: Response<Body>| add_ssz_content_type_header(res))
|
||||
.map(|res: Response<Body>| add_consensus_version_header(res, fork_name))
|
||||
.map(|res| add_execution_payload_blinded_header(res, execution_payload_blinded))
|
||||
.map(|res: Response<Body>| {
|
||||
@@ -196,9 +195,9 @@ pub fn build_response_v2<T: BeaconChainTypes>(
|
||||
match accept_header {
|
||||
Some(api_types::Accept::Ssz) => Response::builder()
|
||||
.status(200)
|
||||
.header("Content-Type", "application/octet-stream")
|
||||
.body(block_contents.as_ssz_bytes().into())
|
||||
.map(|res: Response<Bytes>| add_consensus_version_header(res, fork_name))
|
||||
.map(|res: Response<Body>| add_ssz_content_type_header(res))
|
||||
.map(|res: Response<Body>| add_consensus_version_header(res, fork_name))
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!("failed to create response: {}", e))
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user