File tree 3 files changed +22
-4
lines changed
3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,6 @@ impl Encoder {
30
30
let mut buf: Vec < u8 > = vec ! [ ] ;
31
31
32
32
let mut url = req. url ( ) . path ( ) . to_owned ( ) ;
33
- if let Some ( fragment) = req. url ( ) . fragment ( ) {
34
- url. push ( '#' ) ;
35
- url. push_str ( fragment) ;
36
- }
37
33
if let Some ( query) = req. url ( ) . query ( ) {
38
34
url. push ( '?' ) ;
39
35
url. push_str ( query) ;
Original file line number Diff line number Diff line change @@ -80,3 +80,21 @@ async fn test_encode_request_with_connect() {
80
80
81
81
case. assert ( ) . await ;
82
82
}
83
+
84
+ // The fragment of an URL is not send to the server, see RFC7230 and RFC3986.
85
+ #[ async_std:: test]
86
+ async fn test_encode_request_with_fragment ( ) {
87
+ let case = TestCase :: new_client (
88
+ "fixtures/request-with-fragment.txt" ,
89
+ "fixtures/response-with-host.txt" ,
90
+ )
91
+ . await ;
92
+
93
+ let url = Url :: parse ( "http://example.com/path?query#fragment" ) . unwrap ( ) ;
94
+ let req = Request :: new ( Method :: Get , url) ;
95
+
96
+ let res = client:: connect ( case. clone ( ) , req) . await . unwrap ( ) ;
97
+ assert_eq ! ( res. status( ) , StatusCode :: Ok ) ;
98
+
99
+ case. assert ( ) . await ;
100
+ }
Original file line number Diff line number Diff line change
1
+ GET /path?query HTTP/1.1
2
+ host: example.com
3
+ content-length: 0
4
+
You can’t perform that action at this time.
0 commit comments