diff --git a/src/shrpx_spdy_session.cc b/src/shrpx_spdy_session.cc index 6393b38a..e5638b34 100644 --- a/src/shrpx_spdy_session.cc +++ b/src/shrpx_spdy_session.cc @@ -59,8 +59,7 @@ SpdySession::SpdySession(event_base *evbase, SSL_CTX *ssl_ctx) notified_(false), wrbev_(nullptr), rdbev_(nullptr), - flow_control_(false), - proxy_htp_(0) + flow_control_(false) {} SpdySession::~SpdySession() @@ -109,8 +108,7 @@ int SpdySession::disconnect() } if(proxy_htp_) { - delete proxy_htp_; - proxy_htp_ = 0; + proxy_htp_.reset(); } notified_ = false; @@ -386,8 +384,8 @@ int SpdySession::initiate_connection() bev_ = 0; return SHRPX_ERR_NETWORK; } - proxy_htp_ = new http_parser(); - http_parser_init(proxy_htp_, HTTP_RESPONSE); + proxy_htp_ = util::make_unique(); + http_parser_init(proxy_htp_.get(), HTTP_RESPONSE); proxy_htp_->data = this; state_ = PROXY_CONNECTING; @@ -514,12 +512,12 @@ int SpdySession::on_read_proxy() evbuffer *input = bufferevent_get_input(bev_); unsigned char *mem = evbuffer_pullup(input, -1); - size_t nread = http_parser_execute(proxy_htp_, &htp_hooks, + size_t nread = http_parser_execute(proxy_htp_.get(), &htp_hooks, reinterpret_cast(mem), evbuffer_get_length(input)); evbuffer_drain(input, nread); - http_errno htperr = HTTP_PARSER_ERRNO(proxy_htp_); + http_errno htperr = HTTP_PARSER_ERRNO(proxy_htp_.get()); if(htperr == HPE_OK) { return 0; } else { diff --git a/src/shrpx_spdy_session.h b/src/shrpx_spdy_session.h index e07ddd41..c463f440 100644 --- a/src/shrpx_spdy_session.h +++ b/src/shrpx_spdy_session.h @@ -28,6 +28,7 @@ #include "shrpx.h" #include +#include #include @@ -129,7 +130,7 @@ private: bufferevent *rdbev_; bool flow_control_; // Used to parse the response from HTTP proxy - http_parser *proxy_htp_; + std::unique_ptr proxy_htp_; }; } // namespace shrpx