Use tide::Response.header() instead of tide::Response.remove_header()
@@ -11,15 +11,13 @@ async fn test_status() {
#[async_std::test]
async fn byte_vec_content_type() {
use async_std::io::Cursor;
- use http_types::headers::{HeaderName, HeaderValue};
+ use http_types::headers::HeaderName;
use std::str::FromStr;
let mut resp = Response::new(StatusCode::Ok).body(Cursor::new("foo"));
- let mut header_values: Vec<HeaderValue> = Vec::new();
- let content_type = HeaderName::from_str("Content-Type").unwrap();
- if let Some(x) = resp.remove_header(&content_type) {
- header_values = x;
- }
+ let header_values = resp
+ .header(&HeaderName::from_str("Content-Type").unwrap())
+ .unwrap();
assert_eq!(header_values[0], mime::APPLICATION_OCTET_STREAM.to_string());
let foo = resp.take_body().into_string().await.unwrap();
assert_eq!(foo.as_bytes(), b"foo");
@@ -27,15 +25,13 @@ async fn byte_vec_content_type() {
#[async_std::test]
async fn string_content_type() {
- use http_types::headers::{HeaderName, HeaderValue};
+ use http_types::headers::HeaderName;
use std::str::FromStr;
let mut resp = Response::new(StatusCode::Ok).body_string("foo".to_string());
- let mut header_values: Vec<HeaderValue> = Vec::new();
- let content_type = HeaderName::from_str("Content-Type").unwrap();
- if let Some(x) = resp.remove_header(&content_type) {
- header_values = x;
- }
+ let header_values = resp
+ .header(&HeaderName::from_str("Content-Type").unwrap())
+ .unwrap();
assert_eq!(header_values[0], mime::TEXT_PLAIN_UTF_8.to_string());
let foo = resp.take_body().into_string().await.unwrap();
assert_eq!(foo.as_bytes(), b"foo");
