Skip to content

Add default option on head requests#430

Merged
jnunemaker merged 3 commits into
jnunemaker:masterfrom
supremebeing7:maintain_head_across_redirects
Aug 27, 2015
Merged

Add default option on head requests#430
jnunemaker merged 3 commits into
jnunemaker:masterfrom
supremebeing7:maintain_head_across_redirects

Conversation

@supremebeing7
Copy link
Copy Markdown
Contributor

This attempts to resolve #345. I'm pretty confident the code works, but I couldn't get the spec figured out. I left my attempt in there, with the expectation line commented out.

Suggestions welcome/encouraged.

@jnunemaker
Copy link
Copy Markdown
Owner

I'm not comfortable merging without a passing spec and I don't have time to look into this right now. If someone else could help, that would be great.

@supremebeing7
Copy link
Copy Markdown
Contributor Author

Okay, I had some more time and was able to refactor this a bit to make it more easily testable, then add specs.

I went with the "principle of least surprise" approach outlined by xunker, ensuring that head requests maintain the HEAD method across all redirects, unless the user specifies maintain_method_across_redirects: false in the options.

Comment thread lib/httparty.rb
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This means it will do a GET if it is set to false, is that right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Exactly. I wanted to make sure there was still a way to override the new behavior, in case someone wanted to do that.

jnunemaker pushed a commit that referenced this pull request Aug 27, 2015
…ects

Add default option on head requests
@jnunemaker jnunemaker merged commit 87af97f into jnunemaker:master Aug 27, 2015
@xunker
Copy link
Copy Markdown

xunker commented Aug 27, 2015

@supremebeing7 Thanks for taking care of this, I'm glad my research was helpful to you. 👍

@supremebeing7
Copy link
Copy Markdown
Contributor Author

@xunker Very helpful 🎉

@supremebeing7 supremebeing7 deleted the maintain_head_across_redirects branch August 28, 2015 22:57
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.

Head method returns the request content

3 participants