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

GET on FTP URL returns empty status_code() #190

Closed
dtenenba opened this issue Jan 27, 2015 · 2 comments
Closed

GET on FTP URL returns empty status_code() #190

dtenenba opened this issue Jan 27, 2015 · 2 comments

Comments

@dtenenba
Copy link

library(httr)
response <- GET("ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b142_GRCh38/VCF/common_all_20150114_papu.vcf.gz.tbi")
status_code(response) # integer(0)

Even though it looks like the download completed fine and I can write it out:

bin <- content(response, "raw")
writeBin(bin, "/tmp/myfile")

Comparing the size and md5sum of the file downloaded here vs. the same file downloaded to a different directory using my web browser, indicates the two files have identical contents. So the download succeeded, but I don't really have any way of knowing that (do I?) because the status code of the response is empty. I understand that this is an FTP request, not an HTTP request, so maybe I should not expect an HTTP status code here, but I'm not sure how I can tell programmatically if the request was successful.

Thanks.

 Under development (unstable) (2015-01-26 r67627)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
Running under: OS X 10.9.5 (Mavericks)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] httr_0.6.1

loaded via a namespace (and not attached):
[1] stringr_0.6.2

@Ironholds
Copy link
Contributor

I guess what you really want is the FTP return code?

I'm not knowledgeable enough about how RCurl/Curl handles FTP to say how it might be retrieved, but some experimentation I did with the above code indicates that server-side errors are passed to RCurl, and result in a stop. So if we point to a file that doesn't exist:

response2 <- GET("ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606_b142_GRCh38/VCF/common_all_201fsdfsd50114_papu.vcf.gz.tbi")
Error in function (type, msg, asError = TRUE) : RETR response: 550

So, you can at least see if it didn't work ;p. Not sure if this applies to all possible negative responses, however.

@hadley
Copy link
Member

hadley commented May 4, 2015

I don't have any plans to support ftp in httr.

@hadley hadley closed this as completed May 4, 2015
lshep pushed a commit to Bioconductor/AnnotationHub that referenced this issue Aug 23, 2017
Handle it if GET() returns an empty status code, which happens with FTP
URLs (see r-lib/httr#190).
Also handle it if the status code is 302, which just means there was a 
redirect.

This still produces a lot of output from the FTP server. 
Also if Rsamtools is not installed, downloading a dbSNP VCF resource
will cause an error, so some sort of dependency on Rsamtools needs to be declared.


git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/AnnotationHub@98776 bc3139a8-67e5-0310-9ffc-ced21a209358
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

3 participants