Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

writing chapter

  • Loading branch information...
commit b1f88c14e85893db10df8b264bc3ea2ec8085072 1 parent 6a8a41e
@duncantl duncantl authored
View
19 Changes.html
@@ -3,6 +3,23 @@
<title>Change log for RCurl</title>
</head>
<body>
+<h2>1.93-0</h2>
+<dl>
+ <dt>
+ <li> getURLContent()'s header parameter can be TRUE or FALSE. TRUE
+ returns the header along with the body as a list containing just
+ these two elements.
+ <dd>
+
+ <dt>
+ <li> postForm() coerces its arguments to characters so we can pass
+ values of arbitrary types.
+ <dd>
+ <dt>
+ <li> postForm() checks the header in the response and throws an
+ error if the request was not successful.
+ <dd>
+</dl>
<h2>1.92-1</h2>
<dl>
<dt>
@@ -940,6 +957,6 @@
<address><a href="http://www.stat.ucdavis.edu/~duncan">Duncan Temple Lang</a>
<a href=mailto:duncan@wald.ucdavis.edu>&lt;duncan@wald.ucdavis.edu&gt;</a></address>
<!-- hhmts start -->
-Last modified: Sat May 5 15:38:41 PDT 2012
+Last modified: Mon Jun 4 07:02:40 PDT 2012
<!-- hhmts end -->
</body> </html>
View
9,437 CodeGeneration/enum.c.001t.tu
4,742 additions, 4,695 deletions not shown
View
7 CodeGeneration/readHTMLDoc.R
@@ -0,0 +1,7 @@
+library(XML)
+
+opts = xpathSApply(doc, "//p[@class='level0']/a[@name]/following-sibling::span[@class='nroffip']/text()", xmlValue)
+opts = tolower(gsub("_", ".", gsub("CURLOPT_", "", opts)))
+
+library(RCurl)
+actual = listCurlOptions()
View
4 DESCRIPTION
@@ -1,5 +1,5 @@
Package: RCurl
-Version: 1.92-1
+Version: 1.93-0
Title: General network (HTTP/FTP/...) client interface for R
Author: Duncan Temple Lang
SystemRequirements: libcurl (version 7.14.0 or higher) http://curl.haxx.se.
@@ -57,4 +57,4 @@ Collate: aclassesEnums.R
support.S
upload.R
urlExists.R
-
+ zclone.R
View
16 FAQ.html
@@ -92,9 +92,11 @@
uses some GNU make constructs.
Please set the environment variable
MAKE to gmake.
+ </dd>
</dl>
-<h2>Runtime</h2>
+
+<h1>Runtime</h1>
<dl>
<dt>
@@ -176,8 +178,14 @@
<dt> <li> Why does https not work for me?
<dd> Probably because when you compiled/installed libcurl, you didn't have support for
- SSL. You can check this with the command <pre> curl-config
- --feature </pre> If ssl doesn't appear there, you don't have support
+ SSL. You can check this with the command shell
+<pre> curl-config --feature </pre>
+ or the R command
+<pre>
+curlVersion()$features
+</pre>
+
+ If ssl doesn't appear in either of these, you don't have support
for it. You should reinstall curl, having first installed SSL
(e.g. <a href="http://www.openssl.org">openssl</a>).
@@ -532,6 +540,6 @@
<address><a href="http://www.stat.ucdavis.edu/~duncan">Duncan Temple Lang</a>
<a href=mailto:duncan@wald.ucdavis.edu>&lt;duncan@wald.ucdavis.edu&gt;</a></address>
<!-- hhmts start -->
-Last modified: Fri Apr 20 08:15:09 PDT 2012
+Last modified: Thu May 31 21:08:44 PDT 2012
<!-- hhmts end -->
</body> </html>
View
7 NAMESPACE
@@ -62,7 +62,8 @@ export(scp)
export(guessMIMEType)
# do we want a httpPOST.
-export(httpPUT, httpDELETE, httpGET, httpPOST)
+export(httpPUT, httpDELETE, httpGET, httpPOST, httpHEAD)
+export(httpOPTIONS)
export(getFormParams)
@@ -74,3 +75,7 @@ export(curlError)
#export(CURLAUTH_ONLY, CURLAUTH_ANY, CURLAUTH_NTLM, CURLAUTH_ANYSAFE, CURLAUTH_NTLM_WB,
# CURLAUTH_DIGEST_IE, CURLAUTH_BASIC, CURLAUTH_DIGEST, CURLAUTH_GSSNEGOTIATE, CURLAUTH_NONE)
+
+export(clone)
+exportMethods(clone)
+export(getCurlErrorClassNames)
View
7 R/curlError.R
@@ -15,3 +15,10 @@ function(type, msg, asError = TRUE)
fun( structure(list(message = msg, call = sys.call()), class = c(typeName, "GenericCurlError", "error", "condition")) )
}
+
+
+getCurlErrorClassNames =
+function()
+{
+ gsub("^CURLE_", "", names(CURLcodeValues))
+}
View
30 R/dynamic.R
@@ -24,7 +24,7 @@ function(curl = getCurlHandle(), txt = character(), max = NA, value = NULL, verb
#(length(header) == 0 || curHeaderStatus %in% c(-1, 100))
# do we want a \\\n at the end of the string to avoid
# matching lines with white space in the body.
- if(!inBody && (length(str) == 0 || length(grep("^[[:space:]]+$", str)))) {
+ if(!inBody && (length(str) == 0 || length(grep("^[[:space:]]+$", str)))) {
# Found the end of the header so wrapup the text and put it into the header variable
oldHeader = header
header <<- c(txt, "")
@@ -32,11 +32,11 @@ function(curl = getCurlHandle(), txt = character(), max = NA, value = NULL, verb
if(is.na(isHTTP))
isHTTP <<- length(grep("HTTP", header)) > 0
- if(isHTTP) {
- http.header = parseHTTPHeader(c(header, str))
+ if(isHTTP) {
+ http.header = parseHTTPHeader(c(header, str))
- if(http.header[["status"]] == 100) { # && length(http.header) == 2)
- curHeaderStatus <<- 100
+ if(http.header[["status"]] == 100) { # && length(http.header) == 2)
+ curHeaderStatus <<- 100
# see if there are any attributes to keep other than status and statusMessage.
val.ids = setdiff(names(http.header), c("status", "statusMessage", "message")) # ?? should we add "message"
@@ -46,20 +46,20 @@ function(curl = getCurlHandle(), txt = character(), max = NA, value = NULL, verb
header <<- character()
return(nchar(str, "bytes"))
- } else
- curHeaderStatus = http.header[["status"]]
+ } else
+ curHeaderStatus = http.header[["status"]]
- if(length(oldHeader)) {
+ if(length(oldHeader)) {
tmp = setdiff(names(oldHeader), names(header))
if(length(tmp))
header[tmp] <<- oldHeader[tmp]
- }
+ }
- content.type <<- getContentType(http.header, TRUE)
+ content.type <<- getContentType(http.header, TRUE)
- if(is.na(binary))
- binary = isBinaryContent(http.header, list(http.header["Content-Encoding"], content.type) )
+ if(is.na(binary))
+ binary = isBinaryContent(http.header, list(http.header["Content-Encoding"], content.type) )
# This happens when we get a "HTTP/1.1 100 Continue\r\n" and then
@@ -69,8 +69,10 @@ function(curl = getCurlHandle(), txt = character(), max = NA, value = NULL, verb
inBody <<- FALSE
return( nchar(str, "bytes") )
}
- }
-
+ } else { # if(isHTTP)
+
+ }
+
if(verbose)
cat("Setting option to read content-type", content.type[1], "character set", content.type["charset"], "\n")
if(length(content.type) == 0 || (is.na(binary) || binary)) {
View
7 R/form.S
@@ -117,7 +117,7 @@ function(uri, ...,
collapse = "&")
} else
- .params = as.list(.params)
+ .params = lapply(.params, as, "character") # as.list(.params)
if(length(.params) == 0) {
@@ -135,6 +135,11 @@ function(uri, ...,
curlSetOpt(httpget = TRUE, curl = curl)
}
+ if(!is.null(write)) {
+ http.header = parseHTTPHeader(write$header())
+ stop.if.HTTP.error(http.header)
+ }
+
if(!is.null(buf)) {
processContent( as(buf, "raw"), header, .encoding)
} else if(!is.null(write))
View
37 R/getURLContent.R
@@ -12,20 +12,45 @@ function(url, ..., curl = getCurlHandle(.opts = .opts), .encoding = NA, binary =
{
if(!missing(curl))
curlSetOpt(.opts = .opts, curl = curl)
- if(!'headerfunction' %in% names(.opts)) {
+
+ if(is.logical(header)) {
+ returnHeader = header
+ header = dynCurlReader(curl, binary = binary, baseURL = url, isHTTP = isHTTP, encoding = .encoding)
+ } else
+ returnHeader = FALSE
+
+ if(!('headerfunction' %in% names(.opts))) {
# .opts$headerfunction = header$update
protect = missing(header)
- curlSetOpt(curl = curl, .isProtected = protect, headerfunction = header$update)
+ curlSetOpt(curl = curl, .isProtected = protect,
+ headerfunction = header$update)
}
+ if(!isHTTP && !('writefunction' %in% names(.opts))) {
+ # If for example this is scp where there is no header
+ # or headerfunction will never get called. So we have to
+ # set the writefunction as well.
+ # .opts$headerfunction = header$update
+ protect = missing(header)
+ curlSetOpt(curl = curl, .isProtected = protect,
+ writefunction = header$update)
+ }
+
curlPerform(url = url, curl = curl, .opts = .opts)
if(isHTTP && length(header$header())) {
- http.header = parseHTTPHeader(header$header())
- stop.if.HTTP.error(http.header)
+ http.header = parseHTTPHeader(header$header())
+ stop.if.HTTP.error(http.header)
}
-
- header$value()
+
+ if(returnHeader)
+ list(header = if(is(returnHeader, "AsIs"))
+ header$header()
+ else
+ parseHTTPHeader(header$header()),
+ body = header$value())
+ else
+ header$value()
}
stop.if.HTTP.error =
View
5 R/http.R
@@ -7,7 +7,7 @@ function(url, ..., curl = getCurlHandle())
httpPOST =
function(url, ..., curl = getCurlHandle())
{
- getURLContent(url, .opts = list(...), curl = curl, post = 1L)
+ getURLContent(url, .opts = list(customrequest = "POST", ...), curl = curl, post = 1L)
}
PUT = httpPUT =
@@ -44,7 +44,8 @@ function(url, ..., curl = getCurlHandle())
httpOPTIONS =
function(url, ..., curl = getCurlHandle())
{
- getURLContent(url, customrequest = "OPTIONS", ..., curl = curl)
+ ans = getURLContent(url, customrequest = "OPTIONS", ..., curl = curl, header = TRUE)
+ ans$header
}
View
12 R/zclone.R
@@ -0,0 +1,12 @@
+setGeneric("clone", function(x, ...) standardGeneric("clone"))
+setMethod("clone", "ANY", function(x, ...) x)
+
+setMethod("clone", "CURLHandle", function(x, ...) dupCurlHandle(x, ...))
+setMethod("clone", "environment",
+ function(x, ...) {
+ e = new.env(parent = parent.env(x))
+ sapply(ls(x, all = TRUE),
+ function(id)
+ assign(id, get(id, x), e))
+ e
+ })
View
7 inst/examples/GNUmakefile
@@ -22,6 +22,11 @@ endif
# %.html: %.xml $(OMEGA_HOME)/Docs/XSL/Rexample.xsl
# $(XSLTPROC) $(XSLT_FLAGS) --output $@ $(XSL_HTML_STYLE_FILE) $<
-include $(DYN_DOCS)/inst/Make/Makefile
+ifndef DYN_DOCS
+ DYN_DOCS=$(HOME)/Classes/StatComputing/XDynDocs/inst
+endif
+
+include $(DYN_DOCS)/Make/Makefile
+
View
4 inst/examples/concurrent.xml
@@ -3,7 +3,7 @@
<?xml-stylesheet type="text/xsl" href="http://www.omegahat.org/XSL/Rexample.xsl" ?>
-<r:example xmlns:r="http://www.r-project.org"
+<article xmlns:r="http://www.r-project.org"
xmlns:s="http://cm.bell-labs.com/stat/S4"
xmlns:c="http://www.C.org">
<package name="RCurl"/>
@@ -199,4 +199,4 @@ of system resources.
library(RCurl)
</r:init>
-</r:example>
+</article>
View
6 inst/examples/nestedHTML.xml
@@ -2,7 +2,7 @@
<?xml-stylesheet type="text/xsl" href="../../../Docs/XSL/Rexample.xsl" ?>
<?xml-stylesheet type="text/xsl" href="http://www.omegahat.org/XSL/Rexample.xsl" ?>
-<r:example xmlns:r="http://www.r-project.org"
+<article xmlns:r="http://www.r-project.org"
xmlns:s="http://cm.bell-labs.com/stat/S4">
<title>Nested HTML Downloads</title>
@@ -132,7 +132,7 @@ To get the original document also, we have to look inside the
<s:var>streams</s:var> object and ask it for the contents that it
downloaded. This is why we called
<s:func>HTMLReaderXMLParser</s:func> with <s:true/> for the
-<s:param>save</s:param> argument.
+<r:param>save</r:param> argument.
<para/>
@@ -222,4 +222,4 @@ Works
-->
</r:init>
-</r:example>
+</article>
View
7 inst/examples/xmlParse.xml
@@ -3,7 +3,7 @@
<?xml-stylesheet type="text/xsl" href="http://www.omegahat.org/XSL/Rexample.xsl" ?>
-<r:example xmlns:r="http://www.r-project.org"
+<article xmlns:r="http://www.r-project.org"
xmlns:s="http://cm.bell-labs.com/stat/S4">
<package name="RCurl"/>
<title>
@@ -25,7 +25,7 @@ returned from Web queries.
<para/>
-To do this, we need to use the <b>multi</b> interface for libcurl
+To do this, we need to use the <emphasis>multi</emphasis> interface for libcurl
in order to have asynchronous or non-blocking downloading of the document.
The idea is quite simple. We initiate the download and associate a
"writer" to slurp up the body of the HTTP response. This is registered
@@ -283,5 +283,6 @@ substring(txt, 1, nchar(other)) == other
</section>
-</r:example>
+</article>
+
View
9 man/getURL.Rd
@@ -96,6 +96,15 @@ getURLContent(url, ..., curl = getCurlHandle(.opts = .opts), .encoding = NA,
call to \code{dynCurlReader}, e.g. to specify a
function for its \code{value} parameter to
control how the body is post-processed.
+
+ The caller can specify a value of \code{TRUE} or \code{FALSE}
+ for this parameter. \code{TRUE} means that the header will be
+ returned along with the body; \code{FALSE} corresponds to the
+ default and only the body will be returned.
+ When returning the header, it is first parsed via
+ \code{\link{parseHTTPHeader}},
+ unless the value of \code{header} is of class \code{AsIs}.
+ So to get the raw header, pass the argument as \code{header = I(TRUE)}.
}
\item{isHTTP}{a logical value that indicates whether the request an
HTTP request. This is used when determining how to process the response.}
View
2  src/Makevars
@@ -4,7 +4,7 @@ CURL_CONFIG=/usr/local/bin/curl-config
# CURL_LIBS=$(shell $(CURL_CONFIG) --libs)
CURL_CFLAGS=-I/usr/local/include
-CURL_LIBS=-L/usr/local/lib -lcurl
+CURL_LIBS=-L/usr/local/lib -lcurl -lssh2 -lssl -lcrypto -lldap -lssl -lcrypto -lz -lz
# -DRCURL_DEBUG_MEMORY
Please sign in to comment.
Something went wrong with that request. Please try again.