@@ -10,8 +10,6 @@ use http_body::{Body as HttpBody, SizeHint};
10
10
11
11
use super :: DecodedLength ;
12
12
use crate :: common:: Future ;
13
- #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
14
- use crate :: common:: Never ;
15
13
use crate :: common:: { task, watch, Pin , Poll } ;
16
14
#[ cfg( all( feature = "http2" , any( feature = "client" , feature = "server" ) ) ) ]
17
15
use crate :: proto:: h2:: ping;
@@ -29,9 +27,6 @@ type TrailersSender = oneshot::Sender<HeaderMap>;
29
27
#[ must_use = "streams do nothing unless polled" ]
30
28
pub struct Body {
31
29
kind : Kind ,
32
- /// Keep the extra bits in an `Option<Box<Extra>>`, so that
33
- /// Body stays small in the common case (no extras needed).
34
- extra : Option < Box < Extra > > ,
35
30
}
36
31
37
32
enum Kind {
@@ -52,34 +47,6 @@ enum Kind {
52
47
Ffi ( crate :: ffi:: UserBody ) ,
53
48
}
54
49
55
- struct Extra {
56
- /// Allow the client to pass a future to delay the `Body` from returning
57
- /// EOF. This allows the `Client` to try to put the idle connection
58
- /// back into the pool before the body is "finished".
59
- ///
60
- /// The reason for this is so that creating a new request after finishing
61
- /// streaming the body of a response could sometimes result in creating
62
- /// a brand new connection, since the pool didn't know about the idle
63
- /// connection yet.
64
- delayed_eof : Option < DelayEof > ,
65
- }
66
-
67
- #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
68
- type DelayEofUntil = oneshot:: Receiver < Never > ;
69
-
70
- enum DelayEof {
71
- /// Initial state, stream hasn't seen EOF yet.
72
- #[ cfg( any( feature = "http1" , feature = "http2" ) ) ]
73
- #[ cfg( feature = "client" ) ]
74
- NotEof ( DelayEofUntil ) ,
75
- /// Transitions to this state once we've seen `poll` try to
76
- /// return EOF (`None`). This future is then polled, and
77
- /// when it completes, the Body finally returns EOF (`None`).
78
- #[ cfg( any( feature = "http1" , feature = "http2" ) ) ]
79
- #[ cfg( feature = "client" ) ]
80
- Eof ( DelayEofUntil ) ,
81
- }
82
-
83
50
/// A sender half created through [`Body::channel()`].
84
51
///
85
52
/// Useful when wanting to stream chunks from another thread.
@@ -153,7 +120,7 @@ impl Body {
153
120
}
154
121
155
122
fn new ( kind : Kind ) -> Body {
156
- Body { kind, extra : None }
123
+ Body { kind }
157
124
}
158
125
159
126
#[ cfg( all( feature = "http2" , any( feature = "client" , feature = "server" ) ) ) ]
@@ -176,62 +143,6 @@ impl Body {
176
143
body
177
144
}
178
145
179
- #[ cfg( any( feature = "http1" , feature = "http2" ) ) ]
180
- #[ cfg( feature = "client" ) ]
181
- pub ( crate ) fn delayed_eof ( & mut self , fut : DelayEofUntil ) {
182
- self . extra_mut ( ) . delayed_eof = Some ( DelayEof :: NotEof ( fut) ) ;
183
- }
184
-
185
- fn take_delayed_eof ( & mut self ) -> Option < DelayEof > {
186
- self . extra
187
- . as_mut ( )
188
- . and_then ( |extra| extra. delayed_eof . take ( ) )
189
- }
190
-
191
- #[ cfg( any( feature = "http1" , feature = "http2" ) ) ]
192
- fn extra_mut ( & mut self ) -> & mut Extra {
193
- self . extra
194
- . get_or_insert_with ( || Box :: new ( Extra { delayed_eof : None } ) )
195
- }
196
-
197
- fn poll_eof ( & mut self , cx : & mut task:: Context < ' _ > ) -> Poll < Option < crate :: Result < Bytes > > > {
198
- match self . take_delayed_eof ( ) {
199
- #[ cfg( any( feature = "http1" , feature = "http2" ) ) ]
200
- #[ cfg( feature = "client" ) ]
201
- Some ( DelayEof :: NotEof ( mut delay) ) => match self . poll_inner ( cx) {
202
- ok @ Poll :: Ready ( Some ( Ok ( ..) ) ) | ok @ Poll :: Pending => {
203
- self . extra_mut ( ) . delayed_eof = Some ( DelayEof :: NotEof ( delay) ) ;
204
- ok
205
- }
206
- Poll :: Ready ( None ) => match Pin :: new ( & mut delay) . poll ( cx) {
207
- Poll :: Ready ( Ok ( never) ) => match never { } ,
208
- Poll :: Pending => {
209
- self . extra_mut ( ) . delayed_eof = Some ( DelayEof :: Eof ( delay) ) ;
210
- Poll :: Pending
211
- }
212
- Poll :: Ready ( Err ( _done) ) => Poll :: Ready ( None ) ,
213
- } ,
214
- Poll :: Ready ( Some ( Err ( e) ) ) => Poll :: Ready ( Some ( Err ( e) ) ) ,
215
- } ,
216
- #[ cfg( any( feature = "http1" , feature = "http2" ) ) ]
217
- #[ cfg( feature = "client" ) ]
218
- Some ( DelayEof :: Eof ( mut delay) ) => match Pin :: new ( & mut delay) . poll ( cx) {
219
- Poll :: Ready ( Ok ( never) ) => match never { } ,
220
- Poll :: Pending => {
221
- self . extra_mut ( ) . delayed_eof = Some ( DelayEof :: Eof ( delay) ) ;
222
- Poll :: Pending
223
- }
224
- Poll :: Ready ( Err ( _done) ) => Poll :: Ready ( None ) ,
225
- } ,
226
- #[ cfg( any(
227
- not( any( feature = "http1" , feature = "http2" ) ) ,
228
- not( feature = "client" )
229
- ) ) ]
230
- Some ( delay_eof) => match delay_eof { } ,
231
- None => self . poll_inner ( cx) ,
232
- }
233
- }
234
-
235
146
#[ cfg( feature = "ffi" ) ]
236
147
pub ( crate ) fn as_ffi_mut ( & mut self ) -> & mut crate :: ffi:: UserBody {
237
148
match self . kind {
@@ -313,7 +224,7 @@ impl HttpBody for Body {
313
224
mut self : Pin < & mut Self > ,
314
225
cx : & mut task:: Context < ' _ > ,
315
226
) -> Poll < Option < Result < Self :: Data , Self :: Error > > > {
316
- self . poll_eof ( cx)
227
+ self . poll_inner ( cx)
317
228
}
318
229
319
230
fn poll_trailers (
0 commit comments