Update for latest rust
Tracks rust nightly. 7 tests fail -- still finding source
This commit is contained in:
		| @@ -63,6 +63,7 @@ impl Client<HttpConnector> { | ||||
|  | ||||
| } | ||||
|  | ||||
| #[old_impl_check] | ||||
| impl<C: NetworkConnector<S>, S: NetworkStream> Client<C> { | ||||
|  | ||||
|     /// Create a new client with a specific connector. | ||||
| @@ -162,7 +163,7 @@ impl<'a, U: IntoUrl, C: NetworkConnector<S>, S: NetworkStream> RequestBuilder<'a | ||||
|     pub fn send(self) -> HttpResult<Response> { | ||||
|         let RequestBuilder { client, method, url, headers, body } = self; | ||||
|         let mut url = try!(url.into_url()); | ||||
|         debug!("client.request {} {}", method, url); | ||||
|         debug!("client.request {:?} {:?}", method, url); | ||||
|  | ||||
|         let can_have_body = match &method { | ||||
|             &Method::Get | &Method::Head => false, | ||||
| @@ -193,13 +194,13 @@ impl<'a, U: IntoUrl, C: NetworkConnector<S>, S: NetworkStream> RequestBuilder<'a | ||||
|             if res.status.class() != Redirection { | ||||
|                 return Ok(res) | ||||
|             } | ||||
|             debug!("redirect code {} for {}", res.status, url); | ||||
|             debug!("redirect code {:?} for {:?}", res.status, url); | ||||
|  | ||||
|             let loc = { | ||||
|                 // punching borrowck here | ||||
|                 let loc = match res.headers.get::<Location>() { | ||||
|                     Some(&Location(ref loc)) => { | ||||
|                         Some(UrlParser::new().base_url(&url).parse(loc[])) | ||||
|                         Some(UrlParser::new().base_url(&url).parse(&loc[])) | ||||
|                     } | ||||
|                     None => { | ||||
|                         debug!("no Location header"); | ||||
| @@ -217,7 +218,7 @@ impl<'a, U: IntoUrl, C: NetworkConnector<S>, S: NetworkStream> RequestBuilder<'a | ||||
|                     inspect!("Location", u) | ||||
|                 }, | ||||
|                 Err(e) => { | ||||
|                     debug!("Location header had invalid URI: {}", e); | ||||
|                     debug!("Location header had invalid URI: {:?}", e); | ||||
|                     return Ok(res); | ||||
|                 } | ||||
|             }; | ||||
| @@ -242,13 +243,13 @@ pub enum Body<'a> { | ||||
|     /// A Reader does not necessarily know it's size, so it is chunked. | ||||
|     ChunkedBody(&'a mut (Reader + 'a)), | ||||
|     /// For Readers that can know their size, like a `File`. | ||||
|     SizedBody(&'a mut (Reader + 'a), uint), | ||||
|     SizedBody(&'a mut (Reader + 'a), usize), | ||||
|     /// A String has a size, and uses Content-Length. | ||||
|     BufBody(&'a [u8] , uint), | ||||
|     BufBody(&'a [u8] , usize), | ||||
| } | ||||
|  | ||||
| impl<'a> Body<'a> { | ||||
|     fn size(&self) -> Option<uint> { | ||||
|     fn size(&self) -> Option<usize> { | ||||
|         match *self { | ||||
|             Body::SizedBody(_, len) | Body::BufBody(_, len) => Some(len), | ||||
|             _ => None | ||||
| @@ -258,7 +259,7 @@ impl<'a> Body<'a> { | ||||
|  | ||||
| impl<'a> Reader for Body<'a> { | ||||
|     #[inline] | ||||
|     fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { | ||||
|     fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { | ||||
|         match *self { | ||||
|             Body::ChunkedBody(ref mut r) => r.read(buf), | ||||
|             Body::SizedBody(ref mut r, _) => r.read(buf), | ||||
| @@ -343,12 +344,12 @@ fn get_host_and_port(url: &Url) -> HttpResult<(String, Port)> { | ||||
|         Some(host) => host, | ||||
|         None => return Err(HttpUriError(UrlError::EmptyHost)) | ||||
|     }; | ||||
|     debug!("host={}", host); | ||||
|     debug!("host={:?}", host); | ||||
|     let port = match url.port_or_default() { | ||||
|         Some(port) => port, | ||||
|         None => return Err(HttpUriError(UrlError::InvalidPort)) | ||||
|     }; | ||||
|     debug!("port={}", port); | ||||
|     debug!("port={:?}", port); | ||||
|     Ok((host, port)) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -47,10 +47,10 @@ impl Request<Fresh> { | ||||
|  | ||||
|     /// Create a new client request with a specific underlying NetworkStream. | ||||
|     pub fn with_connector<C: NetworkConnector<S>, S: NetworkStream>(method: method::Method, url: Url, connector: &mut C) -> HttpResult<Request<Fresh>> { | ||||
|         debug!("{} {}", method, url); | ||||
|         debug!("{:?} {:?}", method, url); | ||||
|         let (host, port) = try!(get_host_and_port(&url)); | ||||
|  | ||||
|         let stream: S = try!(connector.connect(host[], port, &*url.scheme)); | ||||
|         let stream: S = try!(connector.connect(&host[], port, &*url.scheme)); | ||||
|         let stream = ThroughWriter(BufferedWriter::new(box stream as Box<NetworkStream + Send>)); | ||||
|  | ||||
|         let mut headers = Headers::new(); | ||||
| @@ -110,17 +110,17 @@ impl Request<Fresh> { | ||||
|         //TODO: this needs a test | ||||
|         if let Some(ref q) = self.url.query { | ||||
|             uri.push('?'); | ||||
|             uri.push_str(q[]); | ||||
|             uri.push_str(&q[]); | ||||
|         } | ||||
|  | ||||
|         debug!("writing head: {} {} {}", self.method, uri, self.version); | ||||
|         debug!("writing head: {:?} {:?} {:?}", self.method, uri, self.version); | ||||
|         try!(write!(&mut self.body, "{} {} {}{}", | ||||
|                     self.method, uri, self.version, LINE_ENDING)); | ||||
|  | ||||
|  | ||||
|         let stream = match self.method { | ||||
|             Get | Head => { | ||||
|                 debug!("headers [\n{}]", self.headers); | ||||
|                 debug!("headers [\n{:?}]", self.headers); | ||||
|                 try!(write!(&mut self.body, "{}{}", self.headers, LINE_ENDING)); | ||||
|                 EmptyWriter(self.body.unwrap()) | ||||
|             }, | ||||
| @@ -139,7 +139,7 @@ impl Request<Fresh> { | ||||
|                 // cant do in match above, thanks borrowck | ||||
|                 if chunked { | ||||
|                     let encodings = match self.headers.get_mut::<common::TransferEncoding>() { | ||||
|                         Some(&common::TransferEncoding(ref mut encodings)) => { | ||||
|                         Some(&mut common::TransferEncoding(ref mut encodings)) => { | ||||
|                             //TODO: check if chunked is already in encodings. use HashSet? | ||||
|                             encodings.push(common::transfer_encoding::Encoding::Chunked); | ||||
|                             false | ||||
| @@ -153,7 +153,7 @@ impl Request<Fresh> { | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 debug!("headers [\n{}]", self.headers); | ||||
|                 debug!("headers [\n{:?}]", self.headers); | ||||
|                 try!(write!(&mut self.body, "{}{}", self.headers, LINE_ENDING)); | ||||
|  | ||||
|                 if chunked { | ||||
| @@ -218,7 +218,7 @@ mod tests { | ||||
|         let stream = *req.body.end().unwrap() | ||||
|             .into_inner().downcast::<MockStream>().ok().unwrap(); | ||||
|         let bytes = stream.write.into_inner(); | ||||
|         let s = from_utf8(bytes[]).unwrap(); | ||||
|         let s = from_utf8(&bytes[]).unwrap(); | ||||
|         assert!(!s.contains("Content-Length:")); | ||||
|         assert!(!s.contains("Transfer-Encoding:")); | ||||
|     } | ||||
| @@ -232,7 +232,7 @@ mod tests { | ||||
|         let stream = *req.body.end().unwrap() | ||||
|             .into_inner().downcast::<MockStream>().ok().unwrap(); | ||||
|         let bytes = stream.write.into_inner(); | ||||
|         let s = from_utf8(bytes[]).unwrap(); | ||||
|         let s = from_utf8(&bytes[]).unwrap(); | ||||
|         assert!(!s.contains("Content-Length:")); | ||||
|         assert!(!s.contains("Transfer-Encoding:")); | ||||
|     } | ||||
|   | ||||
| @@ -35,16 +35,16 @@ impl Response { | ||||
|             Some(status) => status, | ||||
|             None => return Err(HttpStatusError) | ||||
|         }; | ||||
|         debug!("{} {}", version, status); | ||||
|         debug!("{:?} {:?}", version, status); | ||||
|  | ||||
|         let headers = try!(header::Headers::from_raw(&mut stream)); | ||||
|         debug!("Headers: [\n{}]", headers); | ||||
|         debug!("Headers: [\n{:?}]", headers); | ||||
|  | ||||
|         let body = if headers.has::<TransferEncoding>() { | ||||
|             match headers.get::<TransferEncoding>() { | ||||
|                 Some(&TransferEncoding(ref codings)) => { | ||||
|                     if codings.len() > 1 { | ||||
|                         debug!("TODO: #2 handle other codings: {}", codings); | ||||
|                         debug!("TODO: #2 handle other codings: {:?}", codings); | ||||
|                     }; | ||||
|  | ||||
|                     if codings.contains(&Chunked) { | ||||
| @@ -88,7 +88,7 @@ impl Response { | ||||
|  | ||||
| impl Reader for Response { | ||||
|     #[inline] | ||||
|     fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { | ||||
|     fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { | ||||
|         self.body.read(buf) | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user