@@ -344,7 +344,7 @@ mod tests {
|
||||
let (req, len) = parse::<http::ServerTransaction, _>(&mut raw).unwrap().unwrap();
|
||||
assert_eq!(len, expected_len);
|
||||
assert_eq!(req.subject.0, ::Method::Get);
|
||||
assert_eq!(req.subject.1, "/echo".parse().unwrap());
|
||||
assert_eq!(req.subject.1, "/echo");
|
||||
assert_eq!(req.version, ::HttpVersion::Http11);
|
||||
assert_eq!(req.headers.len(), 1);
|
||||
assert_eq!(req.headers.get_raw("Host").map(|raw| &raw[0]), Some(b"hyper.rs".as_ref()));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::ops::Deref;
|
||||
use std::str;
|
||||
|
||||
use bytes::Bytes;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ByteStr(Bytes);
|
||||
@@ -38,6 +38,19 @@ impl Deref for ByteStr {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl From<ByteStr> for Bytes {
|
||||
fn from(s: ByteStr) -> Bytes {
|
||||
s.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ByteStr> for BytesMut {
|
||||
fn from(s: ByteStr) -> BytesMut {
|
||||
s.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for ByteStr {
|
||||
fn from(s: &'a str) -> ByteStr {
|
||||
ByteStr(Bytes::from(s))
|
||||
|
||||
Reference in New Issue
Block a user