Skip to content

Send correct response for HEAD requests#3179

Merged
hueniverse merged 1 commit into
hapijs:masterfrom
kanongil:head-request-fix
Aug 21, 2016
Merged

Send correct response for HEAD requests#3179
hueniverse merged 1 commit into
hapijs:masterfrom
kanongil:head-request-fix

Conversation

@kanongil
Copy link
Copy Markdown
Contributor

I noticed that a HEAD request for some of my routes did not send the content-length header, while a normal GET request would. I have updated the logic to properly set the header. This is done by not skipping the marshal step.

This also fixes specific cases where the content-type header could be different for GET and HEAD if it is set during or post marshaling.

FYI, the modified and new test both fail on current master as follows:

Failed tests:

  141) Connection route() responds to HEAD requests for a GET route:

      Expected undefined to equal specified value

      at /hapijs/hapi/test/connection.js:1690:63

  143) Connection route() returns 500 on HEAD requests for failed responses:

      actual expected

      200500

      Expected 200 to equal specified value

      at /hapijs/hapi/test/connection.js:1749:48

@kanongil
Copy link
Copy Markdown
Contributor Author

Rebased to latest master. Any chance you could look into this?

It's a bit unfortunate that GETand HEAD for the same resource can return different content-type headers.

Also, what happened to the travis integration?

@hueniverse hueniverse added the bug Bug or defect label Aug 21, 2016
@hueniverse hueniverse added this to the 15.0.0 milestone Aug 21, 2016
@hueniverse hueniverse self-assigned this Aug 21, 2016
@hueniverse hueniverse merged commit ee91605 into hapijs:master Aug 21, 2016
hueniverse added a commit that referenced this pull request Aug 21, 2016
@lock
Copy link
Copy Markdown

lock Bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock Bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Bug or defect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants