Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
[WIP] Bump mime to 0.3 and hyper to 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Eijebong committed Sep 16, 2017
1 parent 2093c1a commit 7359f84
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ doctest = false

[dependencies]
cookie = {version = "0.6", default-features = false}
hyper = "0.10"
mime = "0.2"
hyper = { version = "0.11", features = ["raw_status"] }
mime = "0.3"
serde = "1.0"
serde_bytes = "0.10"
time = "0.1"

[dev-dependencies]
serde_test = "1.0"
time = "0.1"

[replace]
"hyper:0.11.2" = { git = "https://github.com/hyperium/hyper.git" }
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//! * `cookie::Cookie`
//! * `hyper::header::ContentType`
//! * `hyper::header::Headers`
//! * `hyper::http::RawStatus`
//! * `hyper::method::Method`
//! * `hyper::RawStatus`
//! * `hyper::Method`
//! * `mime::Mime`
//! * `time::Tm`
//!
Expand Down Expand Up @@ -62,8 +62,8 @@ extern crate time;

use cookie::Cookie;
use hyper::header::{ContentType, Headers};
use hyper::http::RawStatus;
use hyper::method::Method;
use hyper::RawStatus;
use hyper::Method;
use mime::Mime;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_bytes::{ByteBuf, Bytes};
Expand Down Expand Up @@ -412,7 +412,7 @@ impl<'a> Serialize for Ser<'a, Headers> {
for header in self.v.iter() {
let name = header.name();
let value = self.v.get_raw(name).unwrap();
serializer.serialize_entry(name, &Value(value, self.pretty))?;
serializer.serialize_entry(name, &Value(&value.iter().map(|v| v.to_vec()).collect::<Vec<Vec<u8>>>(), self.pretty))?;
}
serializer.end()
}
Expand Down Expand Up @@ -466,7 +466,7 @@ impl<'de> Deserialize<'de> for De<Mime> {
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where E: de::Error,
{
v.parse::<Mime>().map(De::new).map_err(|()| {
v.parse::<Mime>().map(De::new).map_err(|_| {
E::custom("could not parse mime type")
})
}
Expand Down
4 changes: 2 additions & 2 deletions tests/supported.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extern crate time;

use cookie::Cookie;
use hyper::header::{ContentType, Headers};
use hyper::http::RawStatus;
use hyper::method::Method;
use hyper::RawStatus;
use hyper::Method;
use hyper_serde::{De, Ser, Serde};
use mime::Mime;
use serde::{Deserialize, Serialize};
Expand Down
16 changes: 7 additions & 9 deletions tests/tokens.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
extern crate cookie;
extern crate hyper;
extern crate hyper_serde;
#[macro_use]
extern crate mime;
extern crate serde;
extern crate serde_test;
extern crate time;

use cookie::Cookie;
use hyper::header::{ContentType, Headers};
use hyper::http::RawStatus;
use hyper::method::Method;
use hyper::RawStatus;
use hyper::Method;
use hyper_serde::{De, Ser, deserialize};
use serde::Deserialize;
use serde_test::{Deserializer, Token, assert_ser_tokens};
Expand All @@ -19,7 +17,7 @@ use time::Duration;

#[test]
fn test_content_type() {
let content_type = ContentType(mime!(Application / Json));
let content_type = ContentType("Application/Json".parse().unwrap());
let tokens = &[Token::Str("application/json")];

assert_ser_tokens(&Ser::new(&content_type), tokens);
Expand Down Expand Up @@ -58,10 +56,10 @@ fn test_headers_not_empty() {
use hyper::header::Host;

let mut headers = Headers::new();
headers.set(Host {
hostname: "baguette".to_owned(),
port: None,
});
headers.set(Host::new(
"baguette",
None
));

// In Hyper 0.9, Headers is internally a HashMap and thus testing this
// with multiple headers is non-deterministic.
Expand Down

0 comments on commit 7359f84

Please sign in to comment.