File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,27 @@ impl<T: AsRef<[u8]>> Body for BoundedBody<T> {
107
107
}
108
108
}
109
109
110
+ /// An HTTP body with an unknown length
111
+ #[ derive( Debug ) ]
112
+ pub struct StreamedBody < S : AsyncRead > ( S ) ;
113
+
114
+ impl < S : AsyncRead > StreamedBody < S > {
115
+ /// Wrap an `AsyncRead` impl in a type that provides a [`Body`] implementation.
116
+ pub fn new ( s : S ) -> Self {
117
+ Self ( s)
118
+ }
119
+ }
120
+ impl < S : AsyncRead > AsyncRead for StreamedBody < S > {
121
+ async fn read ( & mut self , buf : & mut [ u8 ] ) -> crate :: io:: Result < usize > {
122
+ self . 0 . read ( buf) . await
123
+ }
124
+ }
125
+ impl < S : AsyncRead > Body for StreamedBody < S > {
126
+ fn len ( & self ) -> Option < usize > {
127
+ None
128
+ }
129
+ }
130
+
110
131
impl Body for Empty {
111
132
fn len ( & self ) -> Option < usize > {
112
133
Some ( 0 )
You can’t perform that action at this time.
0 commit comments