File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
extern crate semver;
2
2
3
3
use std:: io:: prelude:: * ;
4
+ use std:: io;
4
5
use std:: collections:: HashMap ;
5
6
use std:: error:: Error ;
6
7
use std:: net:: SocketAddr ;
@@ -129,7 +130,7 @@ pub struct Response {
129
130
pub headers : HashMap < String , Vec < String > > ,
130
131
131
132
/// A Writer for body of the response
132
- pub body : Box < Read + Send >
133
+ pub body : Box < WriteBody + Send >
133
134
}
134
135
135
136
/// A Handler takes a request and returns a response or an error.
@@ -146,3 +147,18 @@ impl<F, E> Handler for F
146
147
( * self ) ( request) . map_err ( |e| Box :: new ( e) as Box < Error +Send > )
147
148
}
148
149
}
150
+
151
+ /// A trait which writes the response body out to a `Write`r.
152
+ ///
153
+ /// This is implemented for all `Read`ers.
154
+ pub trait WriteBody {
155
+ fn write_body ( & mut self , out : & mut Write ) -> io:: Result < u64 > ;
156
+ }
157
+
158
+ impl < R > WriteBody for R
159
+ where R : Read
160
+ {
161
+ fn write_body ( & mut self , out : & mut Write ) -> io:: Result < u64 > {
162
+ io:: copy ( self , out)
163
+ }
164
+ }
You can’t perform that action at this time.
0 commit comments