feat(hyper): switch to std::io, std::net, and std::path.
All instances of `old_io` and `old_path` were switched to use the new shiny `std::io`, `std::net`, and `std::path` modules. This means that `Request` and `Response` implement `Read` and `Write` now. Because of the changes to `TcpListener`, this also takes the opportunity to correct the method usage of `Server`. As with other languages/frameworks, the server is first created with a handler, and then a host/port is passed to a `listen` method. This reverses what `Server` used to do. Closes #347 BREAKING CHANGE: Check the docs. Everything was touched.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use header::{self, QualityItem};
|
||||
use header::QualityItem;
|
||||
use std::str::FromStr;
|
||||
use std::fmt;
|
||||
|
||||
@@ -49,7 +49,6 @@ impl_list_header!(AcceptLanguage,
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use header::{Header, qitem, Quality, QualityItem};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -142,14 +142,9 @@ impl FromStr for Basic {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::old_io::MemReader;
|
||||
use super::{Authorization, Basic};
|
||||
use super::super::super::{Headers};
|
||||
|
||||
fn mem(s: &str) -> MemReader {
|
||||
MemReader::new(s.as_bytes().to_vec())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_raw_auth() {
|
||||
let mut headers = Headers::new();
|
||||
@@ -159,7 +154,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();
|
||||
let headers = Headers::from_raw(&mut b"Authorization: foo bar baz\r\n\r\n").unwrap();
|
||||
assert_eq!(&headers.get::<Authorization<String>>().unwrap().0[..], "foo bar baz");
|
||||
}
|
||||
|
||||
@@ -179,7 +174,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_basic_auth_parse() {
|
||||
let headers = Headers::from_raw(&mut mem("Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\r\n\r\n")).unwrap();
|
||||
let headers = Headers::from_raw(&mut b"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.password, Some("open sesame".to_string()));
|
||||
@@ -187,7 +182,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_basic_auth_parse_no_password() {
|
||||
let headers = Headers::from_raw(&mut mem("Authorization: Basic QWxhZGRpbjo=\r\n\r\n")).unwrap();
|
||||
let headers = Headers::from_raw(&mut b"Authorization: Basic QWxhZGRpbjo=\r\n\r\n").unwrap();
|
||||
let auth = headers.get::<Authorization<Basic>>().unwrap();
|
||||
assert_eq!(auth.0.username.as_slice(), "Aladdin");
|
||||
assert_eq!(auth.0.password, Some("".to_string()));
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use header::{Header, HeaderFormat};
|
||||
use Port;
|
||||
use std::fmt;
|
||||
use header::parsing::from_one_raw_str;
|
||||
|
||||
@@ -15,7 +14,7 @@ pub struct Host {
|
||||
/// The hostname, such a example.domain.
|
||||
pub hostname: String,
|
||||
/// An optional port number.
|
||||
pub port: Option<Port>
|
||||
pub port: Option<u16>
|
||||
}
|
||||
|
||||
impl Header for Host {
|
||||
|
||||
Reference in New Issue
Block a user