diff --git a/include/opendht/http.h b/include/opendht/http.h index e8aba77395237ab43de00c6ac3f7baff2f7953c7..b7b7d1f3ac7c7471f70589c5ce289fcbd66b7d61 100644 --- a/include/opendht/http.h +++ b/include/opendht/http.h @@ -202,12 +202,15 @@ private: std::shared_ptr<dht::Logger> logger_; }; +class Request; + struct Response { unsigned int status_code {0}; std::map<std::string, std::string> headers; std::string body; bool aborted {false}; + std::weak_ptr<Request> request; }; class OPENDHT_PUBLIC Request : public std::enable_shared_from_this<Request> diff --git a/src/http.cpp b/src/http.cpp index 2eb644bbf318b6fca0dc00159575f9ea275efbe1..62409a1c3c71815c4537747cb030dde666127d25 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -694,6 +694,8 @@ Request::notify_state_change(State state) { void Request::init_parser() { + response_.request = shared_from_this(); + if (!parser_) parser_ = std::make_unique<http_parser>(); http_parser_init(parser_.get(), HTTP_RESPONSE);