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

Commit

Permalink
bump hyper to 0.10 and cookie to 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
avadacatavra committed Feb 21, 2017
1 parent ffe469f commit b765541
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "hyper_serde"
version = "0.5.0"
version = "0.6.0"
authors = ["Anthony Ramine <n.oxyde@gmail.com>"]
description = "Serde support for Hyper types"
license = "MIT/Apache-2.0"
Expand All @@ -16,10 +16,11 @@ travis-ci = { repository = "nox/hyper_serde" }
doctest = false

[dependencies]
cookie = {version = "0.2", default-features = false}
hyper = {version = "0.9", default-features = false}
cookie = {version = "0.6", default-features = false}
hyper = "0.10"
mime = "0.2"
serde = "0.9"

[dev-dependencies]
serde_test = "0.9"
time = "0.1"
7 changes: 4 additions & 3 deletions src/lib.rs
Expand Up @@ -270,14 +270,14 @@ impl<'a> Serialize for Ser<'a, ContentType> {
}
}

impl Deserialize for De<Cookie> {
impl Deserialize for De<Cookie<'static>> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer,
{
struct CookieVisitor;

impl Visitor for CookieVisitor {
type Value = De<Cookie>;
type Value = De<Cookie<'static>>;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "an HTTP cookie header value")
Expand All @@ -287,6 +287,7 @@ impl Deserialize for De<Cookie> {
where E: de::Error,
{
Cookie::parse(v)
.map(Cookie::into_owned)
.map(De::new)
.map_err(|e| E::custom(format!("{:?}", e)))
}
Expand All @@ -296,7 +297,7 @@ impl Deserialize for De<Cookie> {
}
}

impl<'a> Serialize for Ser<'a, Cookie> {
impl<'a> Serialize for Ser<'a, Cookie<'a>> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,
{
Expand Down
22 changes: 9 additions & 13 deletions tests/tokens.rs
Expand Up @@ -5,6 +5,7 @@ extern crate hyper_serde;
extern crate mime;
extern crate serde;
extern crate serde_test;
extern crate time;

use cookie::Cookie;
use hyper::header::{ContentType, Headers};
Expand All @@ -14,6 +15,7 @@ use hyper_serde::{De, Ser, deserialize};
use serde::Deserialize;
use serde_test::{Deserializer, Token, assert_ser_tokens};
use std::fmt::Debug;
use time::Duration;

#[test]
fn test_content_type() {
Expand All @@ -26,19 +28,13 @@ fn test_content_type() {

#[test]
fn test_cookie() {
use std::collections::BTreeMap;

let cookie = Cookie {
name: "Hello".to_owned(),
value: "World!".to_owned(),
expires: None,
max_age: Some(42),
domain: Some("servo.org".to_owned()),
path: Some("/".to_owned()),
secure: true,
httponly: false,
custom: BTreeMap::new(),
};
let cookie = Cookie::build("Hello", "World!")
.max_age(Duration::seconds(42))
.domain("servo.org")
.path("/")
.secure(true)
.http_only(false)
.finish();

let tokens = &[Token::Str("Hello=World!; Secure; Path=/; \
Domain=servo.org; Max-Age=42")];
Expand Down

0 comments on commit b765541

Please sign in to comment.