Skip to content

Update hyper to latest nightly #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
2 changes: 1 addition & 1 deletion benches/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(core, io, test)]
#![feature(core, old_io, test)]
extern crate hyper;

extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion benches/client_mock_tcp.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(collections, io, test)]
#![feature(collections, old_io, test)]
extern crate hyper;

extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion benches/server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(io, test)]
#![feature(old_io, test)]
extern crate hyper;
extern crate test;

Expand Down
2 changes: 1 addition & 1 deletion examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(env, io)]
#![feature(env, old_io)]
extern crate hyper;

use std::env;
Expand Down
2 changes: 1 addition & 1 deletion examples/hello.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(io)]
#![feature(old_io)]
extern crate hyper;

use std::old_io::net::ip::Ipv4Addr;
Expand Down
4 changes: 2 additions & 2 deletions examples/server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(io)]
#![feature(old_io)]
extern crate hyper;
#[macro_use] extern crate log;

Expand All @@ -21,7 +21,7 @@ macro_rules! try_return(

fn echo(mut req: Request, mut res: Response) {
match req.uri {
AbsolutePath(ref path) => match (&req.method, &path[]) {
AbsolutePath(ref path) => match (&req.method, &path[..]) {
(&Get, "/") | (&Get, "/echo") => {
let out = b"Try POST /echo";

Expand Down
4 changes: 2 additions & 2 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl<'a, U: IntoUrl, C: NetworkConnector> RequestBuilder<'a, U, C> {
// 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");
Expand Down Expand Up @@ -394,7 +394,7 @@ mod tests {
#[test]
fn test_redirect_followif() {
fn follow_if(url: &Url) -> bool {
!url.serialize()[].contains("127.0.0.3")
!url.serialize().contains("127.0.0.3")
}
let mut client = Client::with_connector(MockRedirectPolicy);
client.set_redirect_policy(RedirectPolicy::FollowIf(follow_if));
Expand Down
15 changes: 10 additions & 5 deletions src/client/request.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Client Requests
use std::old_io::{BufferedWriter, IoResult};
use std::marker::PhantomData;

use url::Url;

Expand All @@ -25,6 +26,8 @@ pub struct Request<W> {
body: HttpWriter<BufferedWriter<Box<NetworkStream + Send>>>,
headers: Headers,
method: method::Method,

_marker: PhantomData<W>,
}

impl<W> Request<W> {
Expand Down Expand Up @@ -66,7 +69,8 @@ impl Request<Fresh> {
headers: headers,
url: url,
version: version::HttpVersion::Http11,
body: stream
body: stream,
_marker: PhantomData,
})
}

Expand All @@ -77,7 +81,7 @@ 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);
Expand Down Expand Up @@ -136,7 +140,8 @@ impl Request<Fresh> {
headers: self.headers,
url: self.url,
version: self.version,
body: stream
body: stream,
_marker: PhantomData,
})
}

Expand Down Expand Up @@ -185,7 +190,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:"));
}
Expand All @@ -199,7 +204,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:"));
}
Expand Down
8 changes: 7 additions & 1 deletion src/client/response.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Client Responses
use std::num::FromPrimitive;
use std::old_io::{BufferedReader, IoResult};
use std::marker::PhantomData;

use header;
use header::{ContentLength, TransferEncoding};
Expand All @@ -23,6 +24,8 @@ pub struct Response<S = HttpStream> {
pub version: version::HttpVersion,
status_raw: RawStatus,
body: HttpReader<BufferedReader<Box<NetworkStream + Send>>>,

_marker: PhantomData<S>,
}

impl Response {
Expand Down Expand Up @@ -72,6 +75,7 @@ impl Response {
headers: headers,
body: body,
status_raw: raw_status,
_marker: PhantomData,
})
}

Expand All @@ -98,6 +102,7 @@ mod tests {
use std::borrow::Cow::Borrowed;
use std::boxed::BoxAny;
use std::old_io::BufferedReader;
use std::marker::PhantomData;

use header::Headers;
use header::TransferEncoding;
Expand All @@ -119,7 +124,8 @@ mod tests {
headers: Headers::new(),
version: version::HttpVersion::Http11,
body: EofReader(BufferedReader::new(box MockStream::new() as Box<NetworkStream + Send>)),
status_raw: RawStatus(200, Borrowed("OK"))
status_raw: RawStatus(200, Borrowed("OK")),
_marker: PhantomData,
};

let b = res.into_inner().downcast::<MockStream>().ok().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/header/common/access_control/allow_origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl header::Header for AccessControlAllowOrigin {

fn parse_header(raw: &[Vec<u8>]) -> Option<AccessControlAllowOrigin> {
if raw.len() == 1 {
match str::from_utf8(unsafe { &raw[].get_unchecked(0)[] }) {
match str::from_utf8(unsafe { &raw.get_unchecked(0)[..] }) {
Ok(s) => {
if s == "*" {
Some(AccessControlAllowOrigin::AllowStar)
Expand Down
14 changes: 7 additions & 7 deletions src/header/common/authorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ impl<S: Scheme> DerefMut for Authorization<S> {
}
}

impl<S: Scheme> Header for Authorization<S> {
impl<S: Scheme + 'static> Header for Authorization<S> where <S as FromStr>::Err: 'static {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, seems odd to need this bound, but I see why. Not something I would immediately think of...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I found this odd too. Took me a while to figure out where to put the bound

fn header_name() -> &'static str {
"Authorization"
}

fn parse_header(raw: &[Vec<u8>]) -> Option<Authorization<S>> {
if raw.len() == 1 {
match (from_utf8(unsafe { &raw[].get_unchecked(0)[] }), Scheme::scheme(None::<S>)) {
match (from_utf8(unsafe { &raw.get_unchecked(0)[..] }), Scheme::scheme(None::<S>)) {
(Ok(header), Some(scheme))
if header.starts_with(scheme) && header.len() > scheme.len() + 1 => {
header[scheme.len() + 1..].parse::<S>().map(|s| Authorization(s)).ok()
Expand All @@ -43,7 +43,7 @@ impl<S: Scheme> Header for Authorization<S> {
}
}

impl<S: Scheme> HeaderFormat for Authorization<S> {
impl<S: Scheme + 'static> HeaderFormat for Authorization<S> where <S as FromStr>::Err: 'static {
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match Scheme::scheme(None::<S>) {
Some(scheme) => try!(write!(fmt, "{} ", scheme)),
Expand Down Expand Up @@ -96,7 +96,7 @@ impl Scheme for Basic {
let mut text = self.username.clone();
text.push(':');
if let Some(ref pass) = self.password {
text.push_str(&pass[]);
text.push_str(&pass[..]);
}
write!(f, "{}", text.as_bytes().to_base64(Config {
char_set: Standard,
Expand All @@ -113,7 +113,7 @@ impl FromStr for Basic {
match s.from_base64() {
Ok(decoded) => match String::from_utf8(decoded) {
Ok(text) => {
let mut parts = &mut text[].split(':');
let mut parts = &mut text.split(':');
let user = match parts.next() {
Some(part) => part.to_string(),
None => return Err(())
Expand Down Expand Up @@ -160,7 +160,7 @@ mod tests {
#[test]
fn test_raw_auth_parse() {
let headers = Headers::from_raw(&mut mem("Authorization: foo bar baz\r\n\r\n")).unwrap();
assert_eq!(&headers.get::<Authorization<String>>().unwrap().0[], "foo bar baz");
assert_eq!(&headers.get::<Authorization<String>>().unwrap().0[..], "foo bar baz");
}

#[test]
Expand All @@ -181,7 +181,7 @@ mod tests {
fn test_basic_auth_parse() {
let headers = Headers::from_raw(&mut mem("Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\r\n\r\n")).unwrap();
let auth = headers.get::<Authorization<Basic>>().unwrap();
assert_eq!(&auth.0.username[], "Aladdin");
assert_eq!(&auth.0.username[..], "Aladdin");
assert_eq!(auth.0.password, Some("open sesame".to_string()));
}

Expand Down
6 changes: 3 additions & 3 deletions src/header/common/cache_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Header for CacheControl {

fn parse_header(raw: &[Vec<u8>]) -> Option<CacheControl> {
let directives = raw.iter()
.filter_map(|line| from_one_comma_delimited(&line[]))
.filter_map(|line| from_one_comma_delimited(&line[..]))
.collect::<Vec<Vec<CacheDirective>>>()
.concat();
if directives.len() > 0 {
Expand All @@ -29,7 +29,7 @@ impl Header for CacheControl {

impl HeaderFormat for CacheControl {
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt_comma_delimited(fmt, &self[])
fmt_comma_delimited(fmt, &self[..])
}
}

Expand Down Expand Up @@ -88,7 +88,7 @@ impl fmt::Display for CacheDirective {
ProxyRevalidate => "proxy-revalidate",
SMaxAge(secs) => return write!(f, "s-maxage={}", secs),

Extension(ref name, None) => &name[],
Extension(ref name, None) => &name[..],
Extension(ref name, Some(ref arg)) => return write!(f, "{}={}", name, arg),

}, f)
Expand Down
2 changes: 1 addition & 1 deletion src/header/common/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Header for Connection {
impl HeaderFormat for Connection {
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let Connection(ref parts) = *self;
fmt_comma_delimited(fmt, &parts[])
fmt_comma_delimited(fmt, &parts[..])
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/header/common/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Header for Cookie {
fn parse_header(raw: &[Vec<u8>]) -> Option<Cookie> {
let mut cookies = Vec::with_capacity(raw.len());
for cookies_raw in raw.iter() {
match from_utf8(&cookies_raw[]) {
match from_utf8(&cookies_raw[..]) {
Ok(cookies_str) => {
for cookie_str in cookies_str.split(';') {
match cookie_str.trim().parse() {
Expand Down Expand Up @@ -82,7 +82,7 @@ impl Cookie {

#[test]
fn test_parse() {
let h = Header::parse_header(&[b"foo=bar; baz=quux".to_vec()][]);
let h = Header::parse_header(&[b"foo=bar; baz=quux".to_vec()][..]);
let c1 = CookiePair::new("foo".to_string(), "bar".to_string());
let c2 = CookiePair::new("baz".to_string(), "quux".to_string());
assert_eq!(h, Some(Cookie(vec![c1, c2])));
Expand All @@ -99,7 +99,7 @@ fn test_fmt() {
let mut headers = Headers::new();
headers.set(cookie_header);

assert_eq!(&headers.to_string()[], "Cookie: foo=bar; baz=quux\r\n");
assert_eq!(&headers.to_string()[..], "Cookie: foo=bar; baz=quux\r\n");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/header/common/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Header for Host {
// FIXME: use rust-url to parse this
// https://github.com/servo/rust-url/issues/42
let idx = {
let slice = &s[];
let slice = &s[..];
if slice.char_at(1) == '[' {
match slice.rfind(']') {
Some(idx) => {
Expand Down
4 changes: 2 additions & 2 deletions src/header/common/if_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Header for IfMatch {

fn parse_header(raw: &[Vec<u8>]) -> Option<IfMatch> {
from_one_raw_str(raw).and_then(|s: String| {
let slice = &s[];
let slice = &s[..];
match slice {
"" => None,
"*" => Some(IfMatch::Any),
Expand All @@ -39,7 +39,7 @@ impl HeaderFormat for IfMatch {
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
IfMatch::Any => write!(fmt, "*"),
IfMatch::EntityTags(ref fields) => fmt_comma_delimited(fmt, &fields[])
IfMatch::EntityTags(ref fields) => fmt_comma_delimited(fmt, &fields[..])
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/header/common/if_none_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Header for IfNoneMatch {

fn parse_header(raw: &[Vec<u8>]) -> Option<IfNoneMatch> {
from_one_raw_str(raw).and_then(|s: String| {
let slice = &s[];
let slice = &s[..];
match slice {
"" => None,
"*" => Some(IfNoneMatch::Any),
Expand All @@ -47,7 +47,7 @@ impl HeaderFormat for IfNoneMatch {
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
IfNoneMatch::Any => { write!(fmt, "*") }
IfNoneMatch::EntityTags(ref fields) => { fmt_comma_delimited(fmt, &fields[]) }
IfNoneMatch::EntityTags(ref fields) => { fmt_comma_delimited(fmt, &fields[..]) }
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/header/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ macro_rules! bench_header(
fn bench_parse(b: &mut Bencher) {
let val = $value;
b.iter(|| {
let _: $ty = Header::parse_header(&val[]).unwrap();
let _: $ty = Header::parse_header(&val[..]).unwrap();
});
}

#[bench]
fn bench_format(b: &mut Bencher) {
let val: $ty = Header::parse_header(&$value[]).unwrap();
let val: $ty = Header::parse_header(&$value[..]).unwrap();
let fmt = HeaderFormatter(&val);
b.iter(|| {
format!("{}", fmt);
Expand Down Expand Up @@ -102,7 +102,7 @@ macro_rules! impl_list_header(

impl $crate::header::HeaderFormat for $from {
fn fmt_header(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
$crate::header::parsing::fmt_comma_delimited(fmt, &self[])
$crate::header::parsing::fmt_comma_delimited(fmt, &self[..])
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/header/common/pragma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Header for Pragma {

fn parse_header(raw: &[Vec<u8>]) -> Option<Pragma> {
parsing::from_one_raw_str(raw).and_then(|s: String| {
let slice = &s.to_ascii_lowercase()[];
let slice = &s.to_ascii_lowercase()[..];
match slice {
"" => None,
"no-cache" => Some(Pragma::NoCache),
Expand Down
Loading