Change HttpResponse creation method.
This commit is contained in:
parent
01ad6bf2d9
commit
9daa5874f5
9 changed files with 55 additions and 18 deletions
|
@ -40,18 +40,23 @@ static const char *kTransferEncoding = "Transfer-Encoding";
|
|||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::HttpResponse::HttpResponse() :
|
||||
parser(nullptr),
|
||||
xmrig::HttpResponse::HttpResponse(uint64_t id) :
|
||||
statusCode(HTTP_STATUS_OK),
|
||||
body(""),
|
||||
statusAdjective("OK"), // FIXME
|
||||
m_writtenOrEnded(false)
|
||||
m_writtenOrEnded(false),
|
||||
m_id(id)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpResponse::writeOrEnd(const std::string &str, bool end)
|
||||
{
|
||||
HttpContext *context = HttpContext::get(m_id);
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
if (!m_writtenOrEnded) {
|
||||
|
@ -84,8 +89,6 @@ void xmrig::HttpResponse::writeOrEnd(const std::string &str, bool end)
|
|||
uv_buf_t resbuf = uv_buf_init(const_cast<char *>(out.c_str()), out.size());
|
||||
# endif
|
||||
|
||||
HttpContext* context = static_cast<HttpContext*>(parser->data);
|
||||
|
||||
uv_try_write(context->stream(), &resbuf, 1);
|
||||
|
||||
if (end) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue