[R-pkg-devel] download.file and https
Paul Gilbert
pgilbert902 at gmail.com
Fri Jul 3 04:46:43 CEST 2015
(This problem with download.file() affects quantmod, and possibly
several other packages. e.g. getSymbols('M2',src='FRED') fails.)
I think the St Louis Fed has moved to using https for connections, and I
believe all the US government web sites are doing this. An http request
is automatically switched to https. The default download.file method
does not seem to handle this, but method="wget" does:
> tmp <- tempfile()
>
download.file("http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv",
destfile = tmp)
trying URL
'http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv'
Error in
download.file("http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv",
:
cannot open URL
'http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv'
>
>
>
download.file("http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv",
destfile = tmp, method="wget")
--2015-07-02 22:29:49--
http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv
Resolving research.stlouisfed.org (research.stlouisfed.org)... 65.89.18.120
Connecting to research.stlouisfed.org
(research.stlouisfed.org)|65.89.18.120|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location:
https://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv
[following]
--2015-07-02 22:29:49--
https://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv
Connecting to research.stlouisfed.org
(research.stlouisfed.org)|65.89.18.120|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/x-comma-separated-values]
Saving to: ‘/tmp/RtmpOX7kA1/file1ba639d7fd0f’
[ <=> ] 34,519 178KB/s in
0.2s
2015-07-02 22:29:50 (178 KB/s) - ‘/tmp/RtmpOX7kA1/file1ba639d7fd0f’
saved [34519]
Paul
More information about the R-package-devel
mailing list