Skip to content

Commit

Permalink
fix test order dep
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Nov 6, 2019
1 parent 885ff73 commit f7f410d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
44 changes: 23 additions & 21 deletions actix-http/src/h1/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,11 @@ mod tests {
ConnectionType::Close,
&ServiceConfig::default(),
);
assert_eq!(
bytes.take().freeze(),
Bytes::from_static(b"\r\nContent-Length: 0\r\nConnection: close\r\nDate: date\r\nContent-Type: plain/text\r\n\r\n")
);
let data = String::from_utf8(Vec::from(bytes.take().freeze().as_ref())).unwrap();
assert!(data.contains("Content-Length: 0\r\n"));
assert!(data.contains("Connection: close\r\n"));
assert!(data.contains("Content-Type: plain/text\r\n"));
assert!(data.contains("Date: date\r\n"));

let _ = head.encode_headers(
&mut bytes,
Expand All @@ -560,10 +561,10 @@ mod tests {
ConnectionType::KeepAlive,
&ServiceConfig::default(),
);
assert_eq!(
bytes.take().freeze(),
Bytes::from_static(b"\r\nTransfer-Encoding: chunked\r\nDate: date\r\nContent-Type: plain/text\r\n\r\n")
);
let data = String::from_utf8(Vec::from(bytes.take().freeze().as_ref())).unwrap();
assert!(data.contains("Transfer-Encoding: chunked\r\n"));
assert!(data.contains("Content-Type: plain/text\r\n"));
assert!(data.contains("Date: date\r\n"));

let _ = head.encode_headers(
&mut bytes,
Expand All @@ -572,10 +573,10 @@ mod tests {
ConnectionType::KeepAlive,
&ServiceConfig::default(),
);
assert_eq!(
bytes.take().freeze(),
Bytes::from_static(b"\r\nContent-Length: 100\r\nDate: date\r\nContent-Type: plain/text\r\n\r\n")
);
let data = String::from_utf8(Vec::from(bytes.take().freeze().as_ref())).unwrap();
assert!(data.contains("Content-Length: 100\r\n"));
assert!(data.contains("Content-Type: plain/text\r\n"));
assert!(data.contains("Date: date\r\n"));

let mut head = RequestHead::default();
head.set_camel_case_headers(false);
Expand All @@ -586,18 +587,18 @@ mod tests {
.append(CONTENT_TYPE, HeaderValue::from_static("xml"));

let mut head = RequestHeadType::Owned(head);

let _ = head.encode_headers(
&mut bytes,
Version::HTTP_11,
BodySize::Stream,
ConnectionType::KeepAlive,
&ServiceConfig::default(),
);
assert_eq!(
bytes.take().freeze(),
Bytes::from_static(b"\r\ntransfer-encoding: chunked\r\ndate: date\r\ncontent-type: xml\r\ncontent-type: plain/text\r\n\r\n")
);
let data = String::from_utf8(Vec::from(bytes.take().freeze().as_ref())).unwrap();
assert!(data.contains("transfer-encoding: chunked\r\n"));
assert!(data.contains("content-type: xml\r\n"));
assert!(data.contains("content-type: plain/text\r\n"));
assert!(data.contains("date: date\r\n"));
}

#[test]
Expand Down Expand Up @@ -626,9 +627,10 @@ mod tests {
ConnectionType::Close,
&ServiceConfig::default(),
);
assert_eq!(
bytes.take().freeze(),
Bytes::from_static(b"\r\ncontent-length: 0\r\nconnection: close\r\nauthorization: another authorization\r\ndate: date\r\n\r\n")
);
let data = String::from_utf8(Vec::from(bytes.take().freeze().as_ref())).unwrap();
assert!(data.contains("content-length: 0\r\n"));
assert!(data.contains("connection: close\r\n"));
assert!(data.contains("authorization: another authorization\r\n"));
assert!(data.contains("date: date\r\n"));
}
}
3 changes: 2 additions & 1 deletion src/guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ pub fn Host<H: AsRef<str>>(host: H) -> HostGuard {

fn get_host_uri(req: &RequestHead) -> Option<Uri> {
use core::str::FromStr;
req.headers.get(header::HOST)
req.headers
.get(header::HOST)
.and_then(|host_value| host_value.to_str().ok())
.or_else(|| req.uri.host())
.map(|host: &str| Uri::from_str(host).ok())
Expand Down

0 comments on commit f7f410d

Please sign in to comment.