omegahat / RCurl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CFILE issue

jmarca opened this issue · comments

I was unable to track this down further, but...

I had some code to PUT attachments to couchdb. Worked on one machine, not on another. The successful machine, a Slackware box, has older GCC and curl

gcc (GCC) 4.8.2
curl --version
curl 7.36.0 (x86_64-unknown-linux-gnu) libcurl/7.36.0 OpenSSL/1.0.1c zlib/1.2.8 libidn/1.25
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp 
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP 

The failing machine is a Gentoo box, and I've just rebuilt everything (emerge -vae world) multiple times to track down a link error, so everything should work fine.

gcc (Gentoo 4.8.4 p1.4, pie-0.6.1) 4.8.4
 curl --version
curl 7.39.0 (x86_64-pc-linux-gnu) libcurl/7.39.0 OpenSSL/1.0.1l zlib/1.2.8 libidn/1.29 libssh2/1.5.0 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP 

In trying to make a test case that failed, I found your testCFile.R, created a new requestb.in target URL, and was unable to get the testCFile code to work. The error looks like:

 > input <- RCurl::CFILE('tests/testthat/files/fig.png')
> RCurl::curlPerform(url = u, customrequest = "PUT", upload = TRUE, readdata = input@ref, infilesize = 100, verbose = TRUE)
 * Hostname was NOT found in DNS cache
 *   Trying 23.21.203.163...
 * Connected to requestb.in (23.21.203.163) port 80 (#0)                                                                                                                                                                                       
 > PUT /1fsh1wa1 HTTP/1.1
 Host: requestb.in
 Accept: */*
 Content-Length: 100
 Expect: 100-continue

 < HTTP/1.1 100 Continue

And there it hung, Emacs spinner twirling idly.

Reading couchdb logs for tests when I hit couchdb, it seems like the connection is made, but no data is passed through, which makes me think that either the way libcurl is using the readdata callback function has changed, or else somehow the C library is behaving differently.

I was able to achieve a successful PUT by using your ftpUpload function:

    content.type <- RCurl::guessMIMEType(attfile, "application/x-binary")
    reader = RCurl::basicTextGatherer()
    res <- RCurl::ftpUpload(what=attfile, to=uri
                           ,httpheader = c('Content-Type'=content.type[[1]])
                           ,customrequest='PUT'
                           ##,verbose=TRUE                                       
                           ,upload=TRUE
                           ,writefunction = reader$update
                           ,curl=h
                            )

(separate issue, but the version on CRAN has a bad "guessMIMEType()", while the version at omegahat.org (1.96) works fine)