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

Curl hangs on HEAD request #24

Closed
hadley opened this issue May 11, 2015 · 3 comments
Closed

Curl hangs on HEAD request #24

hadley opened this issue May 11, 2015 · 3 comments

Comments

@hadley
Copy link
Collaborator

hadley commented May 11, 2015

Not sure what's going wrong here:

library(curl)
h <- new_handle()
handle_setopt(h, customrequest = "HEAD")
curl_fetch_memory("http://google.com", handle = h)

If I cmd + c in a debugger, the backtrace is

(lldb) bt 10
* thread #1: tid = 0x1457395, 0x00007fff838785c2 libsystem_kernel.dylib`poll + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff838785c2 libsystem_kernel.dylib`poll + 10
    frame #1: 0x00007fff8b538378 libcurl.4.dylib`Curl_poll + 140
    frame #2: 0x00007fff8b533791 libcurl.4.dylib`curl_multi_wait + 525
    frame #3: 0x00007fff8b52ccba libcurl.4.dylib`curl_easy_perform + 245
    frame #4: 0x0000000102fe9a79 curl.so`R_curl_fetch_memory + 169
    frame #5: 0x000000010007b2c7 libR.dylib`do_dotcall(call=0x0000000106d20400, op=<unavailable>, args=<unavailable>, env=<unavailable>) + 327 at dotcode.c:1251
    frame #6: 0x00000001000a546c libR.dylib`Rf_eval(e=0x0000000106d20400, rho=0x00000001038cd4b0) + 988 at eval.c:655

It doesn't seem to time out (I waited well over 10s)

@jeroen
Copy link
Owner

jeroen commented May 11, 2015

Maybe this note is related:

When you tell libcurl to do a HEAD request, but then specify a GET though a custom request libcurl will still act as if it sent a HEAD. To switch to a proper HEAD use CURLOPT_NOBODY, to switch to a proper POST use CURLOPT_POST or CURLOPT_POSTFIELDS and to switch to a proper GET use CURLOPT_HTTPGET.

Can you try:

library(curl)
h <- new_handle(nobody = TRUE)
curl_fetch_memory("http://google.com", handle = h)

@jeroen
Copy link
Owner

jeroen commented May 12, 2015

This is solved right?

@jeroen jeroen closed this as completed May 12, 2015
@hadley
Copy link
Collaborator Author

hadley commented May 12, 2015

Yup - for future reference the httr problem was caused by unconditionally setting form fields (which turns the request into a post)

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

No branches or pull requests

2 participants