From 616bfe53b8312251cc071f66ffa8db4bcbfad12b Mon Sep 17 00:00:00 2001 From: XieHan Date: Mon, 11 Jul 2022 23:00:53 +0800 Subject: [PATCH] Add HttpMessage::append_output_body() and append_output_body_nocopy --- src/protocol/HttpMessage.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/protocol/HttpMessage.h b/src/protocol/HttpMessage.h index 3709606c..ebfdc06d 100644 --- a/src/protocol/HttpMessage.h +++ b/src/protocol/HttpMessage.h @@ -131,7 +131,19 @@ public: * msg->get_parsed_body(&body, &size); * msg->append_output_body_nocopy(body, size); */ bool append_output_body(const void *buf, size_t size); + + bool append_output_body(const char *buf) + { + return this->append_output_body(buf, strlen(buf)); + } + bool append_output_body_nocopy(const void *buf, size_t size); + + bool append_output_body_nocopy(const char *buf) + { + return this->append_output_body_nocopy(buf, strlen(buf)); + } + void clear_output_body(); size_t get_output_body_size() const @@ -178,6 +190,11 @@ public: return this->append_output_body(buf.c_str(), buf.size()); } + bool append_output_body_nocopy(const std::string& buf) + { + return this->append_output_body_nocopy(buf.c_str(), buf.size()); + } + protected: http_parser_t *parser; size_t cur_size;