1
1
use bytes:: Bytes ;
2
2
use hyper:: Request ;
3
- use std:: io:: { Cursor , Read } ;
3
+ use std:: io:: Cursor ;
4
4
5
5
use conduit:: {
6
6
header:: { HeaderValue , IntoHeaderName } ,
7
- Extensions , HeaderMap , Method , Uri ,
7
+ Method ,
8
8
} ;
9
9
10
10
pub struct MockRequest {
@@ -42,35 +42,6 @@ impl MockRequest {
42
42
}
43
43
}
44
44
45
- impl conduit:: RequestExt for MockRequest {
46
- fn method ( & self ) -> & Method {
47
- self . request . method ( )
48
- }
49
-
50
- fn uri ( & self ) -> & Uri {
51
- self . request . uri ( )
52
- }
53
-
54
- fn content_length ( & self ) -> Option < u64 > {
55
- Some ( self . request . body ( ) . get_ref ( ) . len ( ) as u64 )
56
- }
57
-
58
- fn headers ( & self ) -> & HeaderMap {
59
- self . request . headers ( )
60
- }
61
-
62
- fn body ( & mut self ) -> & mut dyn Read {
63
- self . request . body_mut ( )
64
- }
65
-
66
- fn extensions ( & self ) -> & Extensions {
67
- self . request . extensions ( )
68
- }
69
- fn extensions_mut ( & mut self ) -> & mut Extensions {
70
- self . request . extensions_mut ( )
71
- }
72
- }
73
-
74
45
impl From < MockRequest > for Request < hyper:: Body > {
75
46
fn from ( mock_request : MockRequest ) -> Self {
76
47
let ( parts, body) = mock_request. request . into_parts ( ) ;
@@ -82,15 +53,14 @@ impl From<MockRequest> for Request<hyper::Body> {
82
53
mod tests {
83
54
use super :: MockRequest ;
84
55
85
- use conduit:: { header, Method , RequestExt } ;
56
+ use conduit:: { header, Method } ;
86
57
87
58
#[ test]
88
59
fn simple_request_test ( ) {
89
60
let req = MockRequest :: new ( Method :: GET , "/" ) . into_inner ( ) ;
90
61
91
62
assert_eq ! ( req. method( ) , Method :: GET ) ;
92
63
assert_eq ! ( req. uri( ) , "/" ) ;
93
- assert_eq ! ( req. content_length( ) , Some ( 0 ) ) ;
94
64
assert_eq ! ( req. headers( ) . len( ) , 0 ) ;
95
65
assert_eq ! ( req. body( ) . get_ref( ) , "" ) ;
96
66
}
@@ -104,7 +74,6 @@ mod tests {
104
74
assert_eq ! ( req. method( ) , Method :: POST ) ;
105
75
assert_eq ! ( req. uri( ) , "/articles" ) ;
106
76
assert_eq ! ( req. body( ) . get_ref( ) , "Hello world" ) ;
107
- assert_eq ! ( req. content_length( ) , Some ( 11 ) ) ;
108
77
}
109
78
110
79
#[ test]
0 commit comments