Skip to content
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

Disable body reading on head requests #95

Merged
merged 9 commits into from
Dec 10, 2021
Merged

Disable body reading on head requests #95

merged 9 commits into from
Dec 10, 2021

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Dec 10, 2021

Fixes #37

Review by @lolgab

@lihaoyi lihaoyi requested a review from lolgab December 10, 2021 09:25
// The HEAD method is identical to GET except that the server
// MUST NOT return a message-body in the response.
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html section 9.4
if (verb.toLowerCase == "head") f(new ByteArrayInputStream(Array()))
Copy link
Member

Choose a reason for hiding this comment

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

The HTTP verbs are case-sensitive. Probably you need to check for HEAD because head or Head are considered extension-methods and don't share the HEAD semantics.

Suggested change
if (verb.toLowerCase == "head") f(new ByteArrayInputStream(Array()))
if (verb == "HEAD") f(new ByteArrayInputStream(Array()))

Copy link
Member Author

Choose a reason for hiding this comment

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

@lolgab updated as per your suggestion

@lolgab
Copy link
Member

lolgab commented Dec 10, 2021

Just out of curiosity, why you needed to introduce the send method?

@lihaoyi
Copy link
Member Author

lihaoyi commented Dec 10, 2021

@lolgab oh thay's accidental. Code meant to be in the other pull request #94. I can pull it out of this PR if you want, or we could just merge them together and update the PR description accordingly

@lolgab
Copy link
Member

lolgab commented Dec 10, 2021

@lihaoyi Oh, now it makes much more sense!
Pehaps you could merge that one first, and then rebase this one.

@lihaoyi
Copy link
Member Author

lihaoyi commented Dec 10, 2021

@lolgab yeah waiting for your review on that one

@@ -1,11 +1,11 @@
package requests

import requests.Requester.methodField
Copy link
Member

@lolgab lolgab Dec 10, 2021

Choose a reason for hiding this comment

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

Is this a spurious change?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, will remove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gzip-encoded HEAD responses throw EOFException
2 participants