1
- #![ feature( io , core, net ) ]
1
+ #![ feature( core) ]
2
2
3
3
extern crate semver;
4
4
extern crate conduit;
5
5
6
6
use std:: collections:: HashMap ;
7
7
use std:: io:: prelude:: * ;
8
8
use std:: io:: Cursor ;
9
- use std:: net:: IpAddr ;
9
+ use std:: net:: { SocketAddr , Ipv4Addr , SocketAddrV4 } ;
10
10
11
11
use semver:: Version ;
12
12
use conduit:: { Method , Scheme , Host , Extensions , Headers , TypeMap } ;
@@ -109,8 +109,8 @@ impl conduit::Request for MockRequest {
109
109
self . query_string . as_ref ( ) . map ( |s| s. as_slice ( ) )
110
110
}
111
111
112
- fn remote_ip ( & self ) -> IpAddr {
113
- IpAddr :: new_v4 ( 127 , 0 , 0 , 1 )
112
+ fn remote_addr ( & self ) -> SocketAddr {
113
+ SocketAddr :: V4 ( SocketAddrV4 :: new ( Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) , 80 ) )
114
114
}
115
115
116
116
fn content_length ( & self ) -> Option < u64 > {
@@ -142,7 +142,7 @@ mod tests {
142
142
use super :: MockRequest ;
143
143
use semver:: Version ;
144
144
145
- use std:: old_io :: net:: ip :: Ipv4Addr ;
145
+ use std:: net:: { SocketAddr , SocketAddrV4 , Ipv4Addr } ;
146
146
147
147
use conduit:: { Request , Method , Host , Scheme } ;
148
148
@@ -158,11 +158,14 @@ mod tests {
158
158
assert_eq ! ( req. virtual_root( ) , None ) ;
159
159
assert_eq ! ( req. path( ) , "/" ) ;
160
160
assert_eq ! ( req. query_string( ) , None ) ;
161
- assert_eq ! ( req. remote_ip( ) , Ipv4Addr ( 127 , 0 , 0 , 1 ) ) ;
161
+ assert_eq ! ( req. remote_addr( ) ,
162
+ SocketAddr :: V4 ( SocketAddrV4 :: new( Ipv4Addr :: new( 127 , 0 , 0 , 1 ) ,
163
+ 80 ) ) ) ;
162
164
assert_eq ! ( req. content_length( ) , None ) ;
163
165
assert_eq ! ( req. headers( ) . all( ) . len( ) , 0 ) ;
164
- assert_eq ! ( req. body( ) . read_to_string( ) . ok( ) . expect( "No body" ) ,
165
- "" . to_string( ) ) ;
166
+ let mut s = String :: new ( ) ;
167
+ req. body ( ) . read_to_string ( & mut s) . ok ( ) . expect ( "No body" ) ;
168
+ assert_eq ! ( s, "" . to_string( ) ) ;
166
169
}
167
170
168
171
#[ test]
@@ -172,8 +175,9 @@ mod tests {
172
175
173
176
assert_eq ! ( req. method( ) , Method :: Post ) ;
174
177
assert_eq ! ( req. path( ) , "/articles" ) ;
175
- assert_eq ! ( req. body( ) . read_to_string( ) . ok( ) . expect( "No body" ) ,
176
- "Hello world" . to_string( ) ) ;
178
+ let mut s = String :: new ( ) ;
179
+ req. body ( ) . read_to_string ( & mut s) . ok ( ) . expect ( "No body" ) ;
180
+ assert_eq ! ( s, "Hello world" . to_string( ) ) ;
177
181
assert_eq ! ( req. content_length( ) , Some ( 11 ) ) ;
178
182
}
179
183
0 commit comments