@@ -103,10 +103,12 @@ where
103103 content_length : Some ( ContentLength { limit, sent } ) ,
104104 ..
105105 } if limit != sent => {
106- store. spawn_fn ( move |_| async move {
107- tx. write ( Err ( ErrorCode :: HttpRequestBodySize ( Some ( sent) ) ) )
108- . await ;
109- Ok ( ( ) )
106+ store. spawn_fn_box ( move |store : & Accessor < U , Self > | {
107+ Box :: pin ( async move {
108+ tx. write ( store, Err ( ErrorCode :: HttpRequestBodySize ( Some ( sent) ) ) )
109+ . await ;
110+ Ok ( ( ) )
111+ } )
110112 } ) ;
111113 return Ok ( Err ( ErrorCode :: HttpRequestBodySize ( Some ( sent) ) ) ) ;
112114 }
@@ -121,10 +123,12 @@ where
121123 let request = http:: Request :: from_parts ( request, body) ;
122124 match client. send_request ( request, options) . await ? {
123125 Ok ( ( response, io) ) => {
124- store. spawn_fn ( |_| async {
125- let res = io. await ;
126- tx. write ( res. map_err ( Into :: into) ) . await ;
127- Ok ( ( ) )
126+ store. spawn_fn_box ( move |store| {
127+ Box :: pin ( async move {
128+ let res = io. await ;
129+ tx. write ( store, res. map_err ( Into :: into) ) . await ;
130+ Ok ( ( ) )
131+ } )
128132 } ) ;
129133 match response. await {
130134 Ok ( response) => response. map ( |body| body. map_err ( Into :: into) . boxed ( ) ) ,
@@ -149,10 +153,12 @@ where
149153 let request = http:: Request :: from_parts ( request, body) ;
150154 match client. send_request ( request, options) . await ? {
151155 Ok ( ( response, io) ) => {
152- store. spawn_fn ( |_| async {
153- let res = io. await ;
154- tx. write ( res. map_err ( Into :: into) ) . await ;
155- Ok ( ( ) )
156+ store. spawn_fn_box ( move |store| {
157+ Box :: pin ( async move {
158+ let res = io. await ;
159+ tx. write ( store, res. map_err ( Into :: into) ) . await ;
160+ Ok ( ( ) )
161+ } )
156162 } ) ;
157163 match response. await {
158164 Ok ( response) => response. map ( |body| body. map_err ( Into :: into) . boxed ( ) ) ,
@@ -169,11 +175,13 @@ where
169175 tx,
170176 content_length : None ,
171177 } => {
172- store. spawn_fn ( {
178+ store. spawn_fn_box ( {
173179 let err = err. clone ( ) ;
174- move |_| async move {
175- tx. write ( Err ( err) ) . await ;
176- Ok ( ( ) )
180+ move |store| {
181+ Box :: pin ( async move {
182+ tx. write ( store, Err ( err) ) . await ;
183+ Ok ( ( ) )
184+ } )
177185 }
178186 } ) ;
179187 return Ok ( Err ( err) ) ;
@@ -197,10 +205,12 @@ where
197205 let request = http:: Request :: from_parts ( request, body) ;
198206 match client. send_request ( request, options) . await ? {
199207 Ok ( ( response, io) ) => {
200- store. spawn_fn ( |_| async {
201- let res = io. await ;
202- tx. write ( res. map_err ( Into :: into) ) . await ;
203- Ok ( ( ) )
208+ store. spawn_fn_box ( |store| {
209+ Box :: pin ( async move {
210+ let res = io. await ;
211+ tx. write ( store, res. map_err ( Into :: into) ) . await ;
212+ Ok ( ( ) )
213+ } )
204214 } ) ;
205215 match response. await {
206216 Ok ( response) => response. map ( |body| body. map_err ( Into :: into) . boxed ( ) ) ,
@@ -239,21 +249,21 @@ where
239249 Ok ( pair) => pair,
240250 Err ( err) => return Ok ( Err ( err) ) ,
241251 } ;
242- store. spawn_fn ( move |_| async move {
252+ store. spawn_fn_box ( move |store| Box :: pin ( async move {
243253 let ( io_res, body_res) = futures:: join! {
244254 io,
245255 async {
246256 body_tx. send( Ok ( buffer) ) . await ?;
247257 let ( mut tail, mut rx_buffer) = contents
248- . read( BytesMut :: with_capacity( DEFAULT_BUFFER_CAPACITY ) )
258+ . read( store , BytesMut :: with_capacity( DEFAULT_BUFFER_CAPACITY ) )
249259 . await ;
250260 loop {
251261 let buffer = rx_buffer. split( ) ;
252262 body_tx. send( Ok ( buffer. freeze( ) ) ) . await ?;
253263 rx_buffer. reserve( DEFAULT_BUFFER_CAPACITY ) ;
254264
255265 match tail {
256- Some ( rest) => ( tail, rx_buffer) = rest. read( rx_buffer) . await ,
266+ Some ( rest) => ( tail, rx_buffer) = rest. read( store , rx_buffer) . await ,
257267 None => break
258268 }
259269
@@ -266,9 +276,9 @@ where
266276 // itself goes away due to cancellation elsewhere, so
267277 // swallow this error.
268278 let _ = body_res;
269- tx. write ( io_res. map_err ( Into :: into) ) . await ;
279+ tx. write ( store , io_res. map_err ( Into :: into) ) . await ;
270280 Ok ( ( ) )
271- } ) ;
281+ } ) ) ;
272282 match response. await {
273283 Ok ( response) => response. map ( |body| body. map_err ( Into :: into) . boxed ( ) ) ,
274284 Err ( err) => return Ok ( Err ( err) ) ,
0 commit comments