Skip to content

Commit

Permalink
Merge pull request #404 from fhartwig/rustup
Browse files Browse the repository at this point in the history
fix: rustup
  • Loading branch information
seanmonstar committed Mar 30, 2015
2 parents 8e1cd5e + c9f2c84 commit ce52315
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
5 changes: 3 additions & 2 deletions src/header/common/authorization.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::fmt;
use std::str::{FromStr, from_utf8};
use std::ops::{Deref, DerefMut};
use std::marker::Reflect;
use serialize::base64::{ToBase64, FromBase64, Standard, Config, Newline};
use header::{Header, HeaderFormat};

Expand All @@ -22,7 +23,7 @@ impl<S: Scheme> DerefMut for Authorization<S> {
}
}

impl<S: Scheme + 'static> Header for Authorization<S> where <S as FromStr>::Err: 'static {
impl<S: Scheme + Reflect + 'static> Header for Authorization<S> where <S as FromStr>::Err: 'static {
fn header_name() -> &'static str {
"Authorization"
}
Expand All @@ -43,7 +44,7 @@ impl<S: Scheme + 'static> Header for Authorization<S> where <S as FromStr>::Err:
}
}

impl<S: Scheme + 'static> HeaderFormat for Authorization<S> where <S as FromStr>::Err: 'static {
impl<S: Scheme + Reflect + '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
9 changes: 5 additions & 4 deletions src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::mem;
use std::path::Path;
use std::raw::{self, TraitObject};
use std::sync::Arc;
use std::marker::Reflect;

use openssl::ssl::{Ssl, SslStream, SslContext};
use openssl::ssl::SslVerifyMode::SslVerifyNone;
Expand Down Expand Up @@ -117,13 +118,13 @@ impl NetworkStream + Send {
impl NetworkStream + Send {
/// Is the underlying type in this trait object a T?
#[inline]
pub fn is<T: 'static>(&self) -> bool {
pub fn is<T: Reflect + 'static>(&self) -> bool {
self.get_type_id() == TypeId::of::<T>()
}

/// If the underlying type is T, get a reference to the contained data.
#[inline]
pub fn downcast_ref<T: 'static>(&self) -> Option<&T> {
pub fn downcast_ref<T: Reflect + 'static>(&self) -> Option<&T> {
if self.is::<T>() {
Some(unsafe { self.downcast_ref_unchecked() })
} else {
Expand All @@ -134,7 +135,7 @@ impl NetworkStream + Send {
/// If the underlying type is T, get a mutable reference to the contained
/// data.
#[inline]
pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> {
pub fn downcast_mut<T: Reflect + 'static>(&mut self) -> Option<&mut T> {
if self.is::<T>() {
Some(unsafe { self.downcast_mut_unchecked() })
} else {
Expand All @@ -143,7 +144,7 @@ impl NetworkStream + Send {
}

/// If the underlying type is T, extract it.
pub fn downcast<T: 'static>(self: Box<NetworkStream + Send>)
pub fn downcast<T: Reflect + 'static>(self: Box<NetworkStream + Send>)
-> Result<Box<T>, Box<NetworkStream + Send>> {
if self.is::<T>() {
Ok(unsafe { self.downcast_unchecked() })
Expand Down
30 changes: 15 additions & 15 deletions src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ impl FromStr for RequestUri {
type Err = HttpError;

fn from_str(s: &str) -> Result<RequestUri, HttpError> {
match s.as_bytes() {
[] => Err(HttpError::HttpUriError(UrlError::InvalidCharacter)),
[b'*'] => Ok(RequestUri::Star),
[b'/', ..] => Ok(RequestUri::AbsolutePath(s.to_string())),
bytes if bytes.contains(&b'/') => {
Ok(RequestUri::AbsoluteUri(try!(Url::parse(s))))
}
_ => {
let mut temp = "http://".to_string();
temp.push_str(s);
try!(Url::parse(&temp[..]));
todo!("compare vs u.authority()");
Ok(RequestUri::Authority(s.to_string()))
}

let bytes = s.as_bytes();
if bytes == [] {
Err(HttpError::HttpUriError(UrlError::InvalidCharacter))
} else if bytes == b"*" {
Ok(RequestUri::Star)
} else if bytes.starts_with(b"/") {
Ok(RequestUri::AbsolutePath(s.to_string()))
} else if bytes.contains(&b'/') {
Ok(RequestUri::AbsoluteUri(try!(Url::parse(s))))
} else {
let mut temp = "http://".to_string();
temp.push_str(s);
try!(Url::parse(&temp[..]));
todo!("compare vs u.authority()");
Ok(RequestUri::Authority(s.to_string()))
}
}
}
Expand Down

0 comments on commit ce52315

Please sign in to comment.