@@ -26,18 +26,18 @@ impl WriteStatus for Streaming {}
26
26
impl WriteStatus for Fresh { }
27
27
28
28
/// The outgoing half for a Tcp connection, created by a `Server` and given to a `Handler`.
29
- pub struct Response < W : WriteStatus , S : NetworkStream > {
29
+ pub struct Response < W : WriteStatus > {
30
30
/// The HTTP version of this response.
31
31
pub version : version:: HttpVersion ,
32
32
// Stream the Response is writing to, not accessible through UnwrittenResponse
33
- body : BufferedWriter < S > , // TODO: use a HttpWriter from rfc7230
33
+ body : BufferedWriter < Box < NetworkStream + Send > > , // TODO: use a HttpWriter from rfc7230
34
34
// The status code for the request.
35
35
status : status:: StatusCode ,
36
36
// The outgoing headers on this response.
37
37
headers : header:: Headers
38
38
}
39
39
40
- impl < W : WriteStatus , S : NetworkStream > Response < W , S > {
40
+ impl < W : WriteStatus > Response < W > {
41
41
/// The status of this response.
42
42
#[ inline]
43
43
pub fn status ( & self ) -> status:: StatusCode { self . status }
@@ -47,9 +47,9 @@ impl<W: WriteStatus, S: NetworkStream> Response<W, S> {
47
47
48
48
/// Construct a Response from its constituent parts.
49
49
pub fn construct ( version : version:: HttpVersion ,
50
- body : BufferedWriter < S > ,
50
+ body : BufferedWriter < Box < NetworkStream + Send > > ,
51
51
status : status:: StatusCode ,
52
- headers : header:: Headers ) -> Response < Fresh , S > {
52
+ headers : header:: Headers ) -> Response < Fresh > {
53
53
Response {
54
54
status : status,
55
55
version : version,
@@ -59,19 +59,19 @@ impl<W: WriteStatus, S: NetworkStream> Response<W, S> {
59
59
}
60
60
}
61
61
62
- impl < S : NetworkStream > Response < Fresh , S > {
62
+ impl Response < Fresh > {
63
63
/// Creates a new Response that can be used to write to a network stream.
64
- pub fn new ( stream : S ) -> Response < Fresh , S > {
64
+ pub fn new < S : NetworkStream > ( stream : S ) -> Response < Fresh > {
65
65
Response {
66
66
status : status:: Ok ,
67
67
version : version:: Http11 ,
68
68
headers : header:: Headers :: new ( ) ,
69
- body : BufferedWriter :: new ( stream)
69
+ body : BufferedWriter :: new ( box stream as Box < NetworkStream + Send > )
70
70
}
71
71
}
72
72
73
73
/// Consume this Response<Fresh>, writing the Headers and Status and creating a Response<Streaming>
74
- pub fn start ( mut self ) -> IoResult < Response < Streaming , S > > {
74
+ pub fn start ( mut self ) -> IoResult < Response < Streaming > > {
75
75
debug ! ( "writing head: {} {}" , self . version, self . status) ;
76
76
try!( write ! ( self . body, "{} {}{}{}" , self . version, self . status, CR as char , LF as char ) ) ;
77
77
@@ -104,20 +104,21 @@ impl<S: NetworkStream> Response<Fresh, S> {
104
104
pub fn headers_mut ( & mut self ) -> & mut header:: Headers { & mut self . headers }
105
105
106
106
/// Deconstruct this Response into its constituent parts.
107
- pub fn deconstruct ( self ) -> ( version:: HttpVersion , BufferedWriter < S > , status:: StatusCode , header:: Headers ) {
107
+ pub fn deconstruct ( self ) -> ( version:: HttpVersion , BufferedWriter < Box < NetworkStream + Send > > ,
108
+ status:: StatusCode , header:: Headers ) {
108
109
( self . version , self . body , self . status , self . headers )
109
110
}
110
111
}
111
112
112
- impl < S : NetworkStream > Response < Streaming , S > {
113
+ impl Response < Streaming > {
113
114
/// Flushes all writing of a response to the client.
114
115
pub fn end ( mut self ) -> IoResult < ( ) > {
115
116
debug ! ( "ending" ) ;
116
117
self . flush ( )
117
118
}
118
119
}
119
120
120
- impl < S : NetworkStream > Writer for Response < Streaming , S > {
121
+ impl Writer for Response < Streaming > {
121
122
fn write ( & mut self , msg : & [ u8 ] ) -> IoResult < ( ) > {
122
123
debug ! ( "write {:u} bytes" , msg. len( ) ) ;
123
124
self . body . write ( msg)
0 commit comments