From c1be28684ac38d6bad550212446df75df3ced66a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 25 Sep 2014 00:15:52 +0900 Subject: [PATCH] libnghttp2_asio: Add request::closed() to indicate that stream has been closed --- src/asio_http2_handler.cc | 10 ++++++++++ src/asio_http2_handler.h | 1 + src/includes/nghttp2/asio_http2.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/src/asio_http2_handler.cc b/src/asio_http2_handler.cc index 51e03b16..7bbe4a27 100644 --- a/src/asio_http2_handler.cc +++ b/src/asio_http2_handler.cc @@ -82,6 +82,11 @@ bool request::pushed() const return impl_->pushed(); } +bool request::closed() const +{ + return impl_->closed(); +} + void request::on_data(data_cb cb) { return impl_->on_data(std::move(cb)); @@ -225,6 +230,11 @@ void request_impl::pushed(bool f) pushed_ = f; } +bool request_impl::closed() const +{ + return handler_.expired() || stream_.expired(); +} + void request_impl::on_data(data_cb cb) { on_data_cb_ = std::move(cb); diff --git a/src/asio_http2_handler.h b/src/asio_http2_handler.h index 839f5109..af59896c 100644 --- a/src/asio_http2_handler.h +++ b/src/asio_http2_handler.h @@ -60,6 +60,7 @@ public: std::vector
headers = {}); bool pushed() const; + bool closed() const; void on_data(data_cb cb); void on_end(void_cb cb); diff --git a/src/includes/nghttp2/asio_http2.h b/src/includes/nghttp2/asio_http2.h index c7fb4fa1..616e94cd 100644 --- a/src/includes/nghttp2/asio_http2.h +++ b/src/includes/nghttp2/asio_http2.h @@ -101,6 +101,9 @@ public: // Returns true if this is pushed request. bool pushed() const; + // Returns true if stream has been closed. + bool closed() const; + // Application must not call this directly. request_impl& impl(); private: