From b4a3e357da93d923a3d5e191a3c4d53969b4707a Mon Sep 17 00:00:00 2001 From: Sebastian Rollen Date: Fri, 19 Apr 2024 13:27:40 -0400 Subject: [PATCH] re-assign req when polling frame --- Cargo.toml | 2 +- src/future.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3028b25..49cdcc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tower-github-webhook" -version = "0.1.1" +version = "0.1.2" edition = "2021" authors = ["Sebastian Rollén "] license = "MIT" diff --git a/src/future.rs b/src/future.rs index 6d63638..b3af550 100644 --- a/src/future.rs +++ b/src/future.rs @@ -6,7 +6,7 @@ use pin_project::pin_project; use sha2::Sha256; use std::future::Future; use std::pin::Pin; -use std::task::{ready, Context, Poll}; +use std::task::{Context, Poll}; use tower::Service; #[pin_project] @@ -98,7 +98,14 @@ where if body.is_end_stream() { curr_state.set(ValidateGitHubWebhookFutureState::ValidateSignature); } else { - let frame = ready!(Pin::new(req.body_mut()).poll_frame(cx)); + let frame = match Pin::new(req.body_mut()).poll_frame(cx) { + Poll::Pending => { + *this.req = Some(req); + return Poll::Pending; + } + Poll::Ready(frame) => frame, + }; + if let Some(Ok(frame)) = frame { if let Ok(data) = frame.into_data() { let mut hmac = this.hmac.take().unwrap();