8000 enh: use the appropriate CURL options for specifying methods by antoine-lizee · Pull Request #357 · r-lib/httr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

enh: use the appropriate CURL options for specifying methods #357

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

Merged
merged 2 commits into from
May 22, 2016

Conversation

antoine-lizee
Copy link
Contributor

cf #356.
A small fix can go a long way :-). I'd advocate for quick publishing to CRAN after inclusion of this PR (or whatever other code change that solves #356).

@@ -99,7 +99,14 @@ print.request <- function(x, ...) {

request_prepare <- function(req) {
req <- request_combine(request_default(), req)
req$options$customrequest <- req$method
switch(req$method,
"POST" = {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please make it more like "POST" = (req$options$post <- TRUE) ?

Copy link
Contributor Author
@antoine-lizee antoine-lizee May 21, 2016

Choose a reason for hiding this comment

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

Why the brackets instead of curly? I'd rather have it be silent? I wouldn't mind putting it on one line if you prefer.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what you mean by silent, but I don't think choice of parens matters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Curly brackets are expressions, they return the result invisibly. Just try:

switch("a", "a" = (tt <- 2))
# [1] 2
switch("a", "a" = {tt <- 2})
# Nothing

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but it really doesn't matter here. Regardless, splitting the expression over multiple lines really bugs me, so please fix.

@hadley
Copy link
Member
hadley commented May 20, 2016

Would you mind also adding a bullet point to NEWS?

And any thoughts on how to test this?

@antoine-lizee
Copy link
Contributor Author
antoine-lizee commented May 21, 2016

NEWS -> Will do
test -> Well, the problem came up with a wrong redirect behavior (see #356), best illustrated with the classic login process POST form -> redirect on success. Nevertheless, as you pointed out quite some time ago (cf postmanlabs/httpbin#156), this is un-testable with httpbin (POSTing to /redirect throws a 405 METHOD NOT ALLOWED). So, no :-(

@hadley
Copy link
Member
hadley commented May 21, 2016

Since testing is hard, could you add a comment mentioning why this behaviour is important? I'm worried I'll forget about it and re-simplify in the future.

@hadley
Copy link
Member
hadley commented May 22, 2016

Thanks!

@hadley hadley merged commit 7cd10ef into r-lib:master May 22, 2016
@hadley
Copy link
Member
hadley commented Jun 13, 2016

Unfortunately this doesn't seem to be correct - setting PUT (which has been deprecated since curl 7.12.0) causes PUT requests to hang for forever on windows. Setting UPLOAD, which is the recommend option, cause it to hang forever on my computer too.

I think this is probably because I'm setting the post body parameters in body_config().

@hadley
Copy link
Member
hadley commented Jun 13, 2016

A bit of googling suggests that using CUSTOMREQUEST is the correct way to do PUTs in libcurl

hadley added a commit that referenced this pull request Jun 14, 2016
@antoine-lizee
Copy link
Contributor Author

Good catch - this is officially a Windows exception to the cURL behaviour, itself being a standard but non-compliant way of dealing with RFC... Why is software getting so crazy?
Thanks!

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.

2 participants
0