File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,6 @@ impl Encoder {
3030 let mut buf: Vec < u8 > = vec ! [ ] ;
3131
3232 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- }
3733 if let Some ( query) = req. url ( ) . query ( ) {
3834 url. push ( '?' ) ;
3935 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() {
8080
8181 case. assert ( ) . await ;
8282}
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