Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/head_response_empty_body.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![feature(async_await)]

use futures::executor::block_on;
use http_service::Body;
use http_service_mock::make_server;
use tide::Context;

async fn ok(_cx: Context<()>) -> String {
String::from("this shouldn't exist in the body of a HEAD response")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we want to make this a persistent test, just having this panic might be reasonable to signify it should never be executed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do that... Maybe something like this, I'm guessing?

Suggested change
String::from("this shouldn't exist in the body of a HEAD response")
panic!("should not go here");
String::from("this shouldn't exist in the body of a HEAD response")

}

#[test]
fn head_response_empty() {
let mut app = tide::App::new();
app.at("/").get(ok);
let mut server = make_server(app.into_http_service()).unwrap();

let req = http::Request::head("/").body(Body::empty()).unwrap();
let res = server.simulate(req).unwrap();
let body = block_on(res.into_body().into_vec()).unwrap();
dbg!(&String::from_utf8(body));
//assert!(body.is_empty());
}