mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 14:14:00 +01:00
rest: don't copy data when sending binary response
Also, change `HTTPRequest::WriteReply` to accept `std::span`.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
|
||||
namespace util {
|
||||
@@ -123,12 +124,16 @@ public:
|
||||
/**
|
||||
* Write HTTP reply.
|
||||
* nStatus is the HTTP status code to send.
|
||||
* strReply is the body of the reply. Keep it empty to send a standard message.
|
||||
* reply is the body of the reply. Keep it empty to send a standard message.
|
||||
*
|
||||
* @note Can be called only once. As this will give the request back to the
|
||||
* main thread, do not call any other HTTPRequest methods after calling this.
|
||||
*/
|
||||
void WriteReply(int nStatus, const std::string& strReply = "");
|
||||
void WriteReply(int nStatus, std::string_view reply = "")
|
||||
{
|
||||
WriteReply(nStatus, std::as_bytes(std::span{reply.data(), reply.size()}));
|
||||
}
|
||||
void WriteReply(int nStatus, std::span<const std::byte> reply);
|
||||
};
|
||||
|
||||
/** Get the query parameter value from request uri for a specified key, or std::nullopt if the key
|
||||
|
||||
Reference in New Issue
Block a user