@@ -248,9 +248,8 @@ static bool rest_headers(const std::any& context,
248
248
ssHeader << pindex->GetBlockHeader ();
249
249
}
250
250
251
- std::string binaryHeader = ssHeader.str ();
252
251
req->WriteHeader (" Content-Type" , " application/octet-stream" );
253
- req->WriteReply (HTTP_OK, binaryHeader );
252
+ req->WriteReply (HTTP_OK, ssHeader );
254
253
return true ;
255
254
}
256
255
@@ -321,9 +320,8 @@ static bool rest_block(const std::any& context,
321
320
322
321
switch (rf) {
323
322
case RESTResponseFormat::BINARY: {
324
- const std::string binaryBlock{block_data.begin (), block_data.end ()};
325
323
req->WriteHeader (" Content-Type" , " application/octet-stream" );
326
- req->WriteReply (HTTP_OK, binaryBlock );
324
+ req->WriteReply (HTTP_OK, std::as_bytes (std::span{block_data}) );
327
325
return true ;
328
326
}
329
327
@@ -451,9 +449,8 @@ static bool rest_filter_header(const std::any& context, HTTPRequest* req, const
451
449
ssHeader << header;
452
450
}
453
451
454
- std::string binaryHeader = ssHeader.str ();
455
452
req->WriteHeader (" Content-Type" , " application/octet-stream" );
456
- req->WriteReply (HTTP_OK, binaryHeader );
453
+ req->WriteReply (HTTP_OK, ssHeader );
457
454
return true ;
458
455
}
459
456
case RESTResponseFormat::HEX: {
@@ -548,9 +545,8 @@ static bool rest_block_filter(const std::any& context, HTTPRequest* req, const s
548
545
DataStream ssResp{};
549
546
ssResp << filter;
550
547
551
- std::string binaryResp = ssResp.str ();
552
548
req->WriteHeader (" Content-Type" , " application/octet-stream" );
553
- req->WriteReply (HTTP_OK, binaryResp );
549
+ req->WriteReply (HTTP_OK, ssResp );
554
550
return true ;
555
551
}
556
552
case RESTResponseFormat::HEX: {
@@ -729,9 +725,8 @@ static bool rest_tx(const std::any& context, HTTPRequest* req, const std::string
729
725
DataStream ssTx;
730
726
ssTx << TX_WITH_WITNESS (tx);
731
727
732
- std::string binaryTx = ssTx.str ();
733
728
req->WriteHeader (" Content-Type" , " application/octet-stream" );
734
- req->WriteReply (HTTP_OK, binaryTx );
729
+ req->WriteReply (HTTP_OK, ssTx );
735
730
return true ;
736
731
}
737
732
@@ -900,10 +895,9 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
900
895
// use exact same output as mentioned in Bip64
901
896
DataStream ssGetUTXOResponse{};
902
897
ssGetUTXOResponse << active_height << active_hash << bitmap << outs;
903
- std::string ssGetUTXOResponseString = ssGetUTXOResponse.str ();
904
898
905
899
req->WriteHeader (" Content-Type" , " application/octet-stream" );
906
- req->WriteReply (HTTP_OK, ssGetUTXOResponseString );
900
+ req->WriteReply (HTTP_OK, ssGetUTXOResponse );
907
901
return true ;
908
902
}
909
903
@@ -981,7 +975,7 @@ static bool rest_blockhash_by_height(const std::any& context, HTTPRequest* req,
981
975
DataStream ss_blockhash{};
982
976
ss_blockhash << pblockindex->GetBlockHash ();
983
977
req->WriteHeader (" Content-Type" , " application/octet-stream" );
984
- req->WriteReply (HTTP_OK, ss_blockhash. str () );
978
+ req->WriteReply (HTTP_OK, ss_blockhash);
985
979
return true ;
986
980
}
987
981
case RESTResponseFormat::HEX: {
0 commit comments