Skip to content
Snippets Groups Projects
Commit 3ba43c80 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

http: add weak_ptr to Request in Response

parent 16333f42
No related branches found
No related tags found
No related merge requests found
...@@ -202,12 +202,15 @@ private: ...@@ -202,12 +202,15 @@ private:
std::shared_ptr<dht::Logger> logger_; std::shared_ptr<dht::Logger> logger_;
}; };
class Request;
struct Response struct Response
{ {
unsigned int status_code {0}; unsigned int status_code {0};
std::map<std::string, std::string> headers; std::map<std::string, std::string> headers;
std::string body; std::string body;
bool aborted {false}; bool aborted {false};
std::weak_ptr<Request> request;
}; };
class OPENDHT_PUBLIC Request : public std::enable_shared_from_this<Request> class OPENDHT_PUBLIC Request : public std::enable_shared_from_this<Request>
......
...@@ -694,6 +694,8 @@ Request::notify_state_change(State state) { ...@@ -694,6 +694,8 @@ Request::notify_state_change(State state) {
void void
Request::init_parser() Request::init_parser()
{ {
response_.request = shared_from_this();
if (!parser_) if (!parser_)
parser_ = std::make_unique<http_parser>(); parser_ = std::make_unique<http_parser>();
http_parser_init(parser_.get(), HTTP_RESPONSE); http_parser_init(parser_.get(), HTTP_RESPONSE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment