@@ -62,14 +62,13 @@ use std::fmt;
6262
6363use std:: time:: Duration ;
6464
65- use url:: UrlParser ;
65+ use url:: Url ;
6666use url:: ParseError as UrlError ;
6767
6868use header:: { Headers , Header , HeaderFormat } ;
6969use header:: { ContentLength , Location } ;
7070use method:: Method ;
7171use net:: { NetworkConnector , NetworkStream } ;
72- use { Url } ;
7372use Error ;
7473
7574pub use self :: pool:: Pool ;
@@ -264,7 +263,7 @@ impl<'a> RequestBuilder<'a> {
264263 loop {
265264 let message = {
266265 let ( host, port) = try!( get_host_and_port ( & url) ) ;
267- try!( client. protocol . new_message ( & host, port, & * url. scheme ) )
266+ try!( client. protocol . new_message ( & host, port, url. scheme ( ) ) )
268267 } ;
269268 let mut req = try!( Request :: with_message ( method. clone ( ) , url. clone ( ) , message) ) ;
270269 headers. as_ref ( ) . map ( |headers| req. headers_mut ( ) . extend ( headers. iter ( ) ) ) ;
@@ -292,7 +291,7 @@ impl<'a> RequestBuilder<'a> {
292291 // punching borrowck here
293292 let loc = match res. headers . get :: < Location > ( ) {
294293 Some ( & Location ( ref loc) ) => {
295- Some ( UrlParser :: new ( ) . base_url ( & url) . parse ( & loc[ .. ] ) )
294+ Some ( url. join ( loc) )
296295 }
297296 None => {
298297 debug ! ( "no Location header" ) ;
@@ -439,13 +438,13 @@ impl Default for RedirectPolicy {
439438 }
440439}
441440
442- fn get_host_and_port ( url : & Url ) -> :: Result < ( String , u16 ) > {
443- let host = match url. serialize_host ( ) {
441+ fn get_host_and_port ( url : & Url ) -> :: Result < ( & str , u16 ) > {
442+ let host = match url. host_str ( ) {
444443 Some ( host) => host,
445444 None => return Err ( Error :: Uri ( UrlError :: EmptyHost ) )
446445 } ;
447446 trace ! ( "host={:?}" , host) ;
448- let port = match url. port_or_default ( ) {
447+ let port = match url. port_or_known_default ( ) {
449448 Some ( port) => port,
450449 None => return Err ( Error :: Uri ( UrlError :: InvalidPort ) )
451450 } ;
@@ -498,7 +497,7 @@ mod tests {
498497 #[ test]
499498 fn test_redirect_followif ( ) {
500499 fn follow_if ( url : & Url ) -> bool {
501- !url. serialize ( ) . contains ( "127.0.0.3" )
500+ !url. as_str ( ) . contains ( "127.0.0.3" )
502501 }
503502 let mut client = Client :: with_connector ( MockRedirectPolicy ) ;
504503 client. set_redirect_policy ( RedirectPolicy :: FollowIf ( follow_if) ) ;
0 commit comments