diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc index d624026b..044d0bf0 100644 --- a/src/shrpx_http_downstream_connection.cc +++ b/src/shrpx_http_downstream_connection.cc @@ -47,13 +47,11 @@ HttpDownstreamConnection::HttpDownstreamConnection (ClientHandler *client_handler) : DownstreamConnection(client_handler), bev_(0), - ioctrl_(0), - response_htp_(new http_parser()) + ioctrl_(0) {} HttpDownstreamConnection::~HttpDownstreamConnection() { - delete response_htp_; if(bev_) { bufferevent_disable(bev_, EV_READ | EV_WRITE); bufferevent_free(bev_); @@ -95,8 +93,8 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) ioctrl_.set_bev(bev_); - http_parser_init(response_htp_, HTTP_RESPONSE); - response_htp_->data = downstream_; + http_parser_init(&response_htp_, HTTP_RESPONSE); + response_htp_.data = downstream_; bufferevent_setwatermark(bev_, EV_READ, 0, SHRPX_READ_WARTER_MARK); bufferevent_enable(bev_, EV_READ); @@ -457,12 +455,12 @@ int HttpDownstreamConnection::on_read() evbuffer_drain(input, inputlen); return rv; } - size_t nread = http_parser_execute(response_htp_, &htp_hooks, + size_t nread = http_parser_execute(&response_htp_, &htp_hooks, reinterpret_cast(mem), inputlen); evbuffer_drain(input, nread); - http_errno htperr = HTTP_PARSER_ERRNO(response_htp_); + http_errno htperr = HTTP_PARSER_ERRNO(&response_htp_); if(htperr == HPE_OK) { return 0; } else { diff --git a/src/shrpx_http_downstream_connection.h b/src/shrpx_http_downstream_connection.h index 82e23d3e..7ee5779b 100644 --- a/src/shrpx_http_downstream_connection.h +++ b/src/shrpx_http_downstream_connection.h @@ -63,7 +63,7 @@ public: private: bufferevent *bev_; IOControl ioctrl_; - http_parser *response_htp_; + http_parser response_htp_; }; } // namespace shrpx