diff --git a/src/asio_client_request_impl.cc b/src/asio_client_request_impl.cc index 1eb0ee7d..4975cefd 100644 --- a/src/asio_client_request_impl.cc +++ b/src/asio_client_request_impl.cc @@ -25,6 +25,7 @@ #include "asio_client_request_impl.h" #include "asio_client_stream.h" +#include "asio_client_session_impl.h" #include "template.h" namespace nghttp2 { @@ -33,7 +34,10 @@ namespace client { request_impl::request_impl() : strm_(nullptr) {} -void request_impl::cancel(uint32_t error_code) { strm_->cancel(error_code); } +void request_impl::cancel(uint32_t error_code) { + auto sess = strm_->session(); + sess->cancel(*strm_, error_code); +} void request_impl::on_response(response_cb cb) { response_cb_ = std::move(cb); } @@ -72,7 +76,10 @@ read_cb::result_type request_impl::call_on_read(uint8_t *buf, std::size_t len, return 0; } -void request_impl::resume() { strm_->resume(); } +void request_impl::resume() { + auto sess = strm_->session(); + sess->resume(*strm_); +} void request_impl::header(header_map h) { header_ = std::move(h); } diff --git a/src/asio_client_stream.cc b/src/asio_client_stream.cc index b4f532a8..aa73413b 100644 --- a/src/asio_client_stream.cc +++ b/src/asio_client_stream.cc @@ -36,10 +36,6 @@ stream::stream(session_impl *sess) : sess_(sess), stream_id_(0) { request_.impl().stream(this); } -void stream::cancel(uint32_t error_code) { sess_->cancel(*this, error_code); } - -void stream::resume() { sess_->resume(*this); } - void stream::stream_id(int32_t stream_id) { stream_id_ = stream_id; } int32_t stream::stream_id() const { return stream_id_; } @@ -48,6 +44,8 @@ request &stream::request() { return request_; } response &stream::response() { return response_; } +session_impl *stream::session() const { return sess_; } + bool stream::expect_final_response() const { return response_.status_code() / 100 == 1; } diff --git a/src/asio_client_stream.h b/src/asio_client_stream.h index 2b1b8c4d..d61053c3 100644 --- a/src/asio_client_stream.h +++ b/src/asio_client_stream.h @@ -44,15 +44,14 @@ public: stream(const stream &) = delete; stream &operator=(const stream &) = delete; - void cancel(uint32_t error_code); - void resume(); - void stream_id(int32_t stream_id); int32_t stream_id() const; request &request(); response &response(); + session_impl *session() const; + bool expect_final_response() const; private: