-
Notifications
You must be signed in to change notification settings - Fork 327
add test that checks for empty body on HEAD req #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add test that checks for empty body on HEAD req #179
Conversation
Looking at it more in detail, I think I know why this doesn't work. Also related to #45 (comment). My intuition was somehow that the http service and http service mock crates were using Hyper underneath -- this is wrong. Instead, the app server just has an implementation for I'll probably start figuring out more on how to do this, but hmm... |
use tide::{error::ResultExt, Context}; | ||
|
||
async fn ok(_cx: Context<()>) -> String { | ||
String::from("this shouldn't exist in the body of a HEAD response") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
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") |
@fairingrey hmm, not sure either. I guess the obvious choice here would be to expand http-service-mock to include this behavior. But that does kind of feel like a band-aid. Hmm, we could also fix this at the tide-level, where if the request is a HEAD we abort early? Not sure which is better here. |
Ping @fairingrey -- do you have an idea how to move forward here? |
Mmm... I think I would rather just change http-service-mock to fit the test here. It is a bandaid, admittedly -- but since we already know how hyper behaves, it should be fine. That said, I do think that approach won't necessitate the panic as you suggested originally here: #179 (comment) (The GET response shouldn't panic, but the HEAD response body should be empty) |
currently not working since http-service-mock doesn't exhibit correct behavior yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge this (:
Attempts to address #45.
Description
This adds a test that checks if a response with an empty body is returned on a HEAD request to a resource where GET behavior exists.
For some reason it fails, so there might be something in
http_service_mock
that needs to be fixed? Attempting an HTTP request to a live server viacurl
/Insomnia exhibits the normal behavior e.g. #45 (comment), but a non-empty body is returned onserver.simulate(req).unwrap()
, as if it was making a GET request normally.EDIT: See my comment below #179 (comment)
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: