Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

new version with Hadley's .postForm fn.

  • Loading branch information...
commit 8cb23e7e0704fd1015bc3df83bafd31304c0d7c3 1 parent c229c26
@duncantl duncantl authored
View
11 Changes.html
@@ -4,10 +4,14 @@
</head>
<body>
-<h2>1.94-1</h2>
+<h2>1.95-0</h2>
<dl>
<dt>
+ <li> Expose interface to C routine for posting a form, .postForm().
+ <dd> Request and patch from Hadley Wickham.
+
+ <dt>
<li> Field httpHeader added to the error/condition object when an
HTTP error is raised.
<dd>
@@ -27,9 +31,6 @@
some parameters specified in the URL
<dd>
- <dt>
- <li> getM
- <dd>
</dl>
@@ -999,6 +1000,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 Jul 20 06:46:07 PDT 2012
+Last modified: Fri Sep 28 18:15:46 PDT 2012
<!-- hhmts end -->
</body> </html>
View
4 DESCRIPTION
@@ -1,11 +1,11 @@
Package: RCurl
-Version: 1.93-0
+Version: 1.95-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.
On Linux systems, you will often have to explicitly install libcurl-devel
to have the header files and the libcurl library.
-Maintainer: Duncan Temple Lang <duncan@wald.ucdavis.edu>
+Maintainer: Duncan Temple Lang <duncan@r-project.org>
Description: The package allows one to compose general HTTP requests
and provides convenient functions to fetch URIs, get & post forms,
etc. and process the results returned by the Web server.
View
1  NAMESPACE
@@ -1,6 +1,7 @@
import(methods)
export(getURL, getURI, postForm, getForm, getURLContent)
+export(.postForm)
export(curlGlobalInit,curlVersion)
export(curlOptions)
export(getCurlInfoConstants, getCurlOptionsConstants, listCurlOptions)
View
48 R/form.S
@@ -4,8 +4,8 @@ getForm =
# The ... here are for the arguments to the form, not the curl options.
#
#
-function(uri, ..., .params = character(), .opts = list(), curl = getCurlHandle(), .encoding = integer(), binary = NA,
- .checkParams = TRUE)
+function(uri, ..., .params = character(), .opts = list(), curl = getCurlHandle(),
+ .encoding = integer(), binary = NA, .checkParams = TRUE)
{
# should we merge params with ....
# for now just one or the other.
@@ -46,6 +46,33 @@ function(.params)
PostStyles = c('HTTPPOST' = NA,
'POST' = as.integer(47))
+matchPostStyle =
+function(style)
+{
+ if(is.na(style))
+ return(style)
+
+ # The style of the post, i.e. HTTPPOST or regular POST,
+ # i.e. www-form-encoded or
+ if(is.character(style)) {
+ i = pmatch(tolower(style), tolower(names(PostStyles)))
+ if(is.na(i))
+ stop("POST style is not recognized: must be one of ", paste(names(PostStyles), collapse = ", "))
+ as.integer(PostStyles[i])
+ } else {
+ if(!(style %in% PostStyles))
+ warning("Unrecognized style value ", style)
+ as.integer(style)
+ }
+}
+
+
+.postForm =
+function(curl, .opts, .params, style = 'HTTPPOST')
+{
+ .Call("R_post_form", curl, .opts, .params, TRUE, matchPostStyle(style), PACKAGE = "RCurl")
+}
+
postForm =
#
# The ... here are for the arguments to the form, not the curl options.
@@ -61,21 +88,7 @@ function(uri, ...,
write = NULL
noCurlOptions = missing(.opts)
-
- if(!is.na(style)) {
- # The style of the post, i.e. HTTPPOST or regular POST,
- # i.e. www-form-encoded or
- if(is.character(style)) {
- i = pmatch(tolower(style), tolower(names(PostStyles)))
- if(is.na(i))
- stop("POST style is not recognized: must be one of ", paste(names(PostStyles), collapse = ", "))
- style = as.integer(PostStyles[i])
- } else {
- if(!(style %in% PostStyles))
- warning("Unrecognized style value ", style)
- style = as.integer(style)
- }
- }
+ style = matchPostStyle(style)
# merge the two sources of inputs
.params = merge(list(...), .params)
@@ -128,6 +141,7 @@ function(uri, ...,
testCurlOptionsInFormParameters(.params)
status = .Call("R_post_form", curl, .opts, .params, TRUE, as.integer(style), PACKAGE = "RCurl")
+ status = .postForm(curl, .opts, .params, style)
if(any(!isProtected)) {
# Reset the httppost field to NULL so we can release the values.
View
23 man/AUTH.Rd
@@ -0,0 +1,23 @@
+\name{AUTH_ANY}
+\alias{AUTH_ANY}
+\alias{AUTH_ANYSAFE}
+\alias{AUTH_BASIC}
+\alias{AUTH_DIGEST}
+\alias{AUTH_DIGEST_IE}
+\alias{AUTH_GSSNEGOTIATE}
+\alias{AUTH_NONE}
+\alias{AUTH_NTLM}
+\alias{AUTH_NTLM_WB}
+\alias{AUTH_ONLY}
+\title{Constants for identifying Authentication Schemes}
+\description{
+ These variables are symbolic constants that allow
+ use to specify different combinations of schemes
+ for HTTP authentication in a request to a Web server.
+ We can combine them via the \code{|} operator to
+ indicate that libcurl should try them in order until one works.
+}
+\examples{
+ AUTH_BASIC | AUTH_DIGEST
+}
+\keyword{programming}
View
7 man/CFILE.Rd
@@ -2,6 +2,7 @@
\Rdversion{1.1}
\alias{CFILE}
\alias{CFILE-class}
+\alias{close,CFILE-method}
\title{Create a C-level handle for a file}
\description{
This function and class allow us to work with C-level
@@ -10,7 +11,11 @@ The intent is to be able to pass these to \code{libcurl}
as options so that it can read or write from or to the file.
We can also do this with R connections and specify callback functions
that manipulate these connections. But using
-the C-level FILE handle is likely to be significantly faster for large files.
+the C-level FILE handle is likely to be significantly faster for large
+files.
+
+ The \code{close} method allows us to explicitly flush and close the file
+ from within R.
}
\usage{
CFILE(filename, mode = "r")
View
8 man/CURLHandle-class.Rd
@@ -24,10 +24,7 @@
\section{Extends}{
Class \code{"oldClass"}, directly.
}
-\section{Methods}{
- \describe{
- }
-}
+%\section{Methods}{ \describe{}}
\references{
\url{http://curl.haxx.se}, the libcurl web site.
}
@@ -39,6 +36,5 @@ Class \code{"oldClass"}, directly.
\code{\link{getCurlHandle}},
\code{\link{MultiCURLHandle-class}}
}
-\examples{
-}
+%\examples{}
\keyword{classes}
View
10 man/CurlFeatureBits.Rd
@@ -19,11 +19,7 @@
\source{
libcurl (see \url{http://curl.haxx.se})
}
-\references{
-}
-\seealso{
-
-}
-\examples{
-}
+%\references{}
+%\seealso{}
+%\examples{}
\keyword{datasets}
View
5 man/HTTP_VERSION_1_0.Rd
@@ -15,11 +15,8 @@ These are values that can be used to set the \code{http.version} and \code{sslve
options of \code{\link{curlPerform}}.
}
\usage{HTTP_VERSION_1_0}
-\details{
-}
\references{
\url{http://curl.haxx.se/libcurl/c/curl_easy_setopt.html}
}
-\examples{
-}
+%\examples{}
\keyword{datasets}
View
4 man/MultiCURLHandle-class.Rd
@@ -59,7 +59,5 @@
\code{\link{curlMultiPerform}}
\code{\link{multiTextGatherer}}
}
-\examples{
-
-}
+%\examples{}
\keyword{classes}
View
3  man/base64.Rd
@@ -44,8 +44,7 @@ This is currently not vectorized.
We might extend this to work with raw objects.
}
-\seealso{
-}
+%\seealso{}
\examples{
# encode and then decode a simple string.
txt = "Some simple text for base 64 to handle"
View
5 man/basicTextGatherer.Rd
@@ -53,7 +53,7 @@
\usage{
basicTextGatherer(txt = character(), max = NA, value = NULL,
.mapUnicode = TRUE)
-multiTextGatherer(uris)
+multiTextGatherer(uris, binary = rep(NA, length(uris)))
debugGatherer()
}
%- maybe also 'usage' for other objects documented here.
@@ -76,7 +76,8 @@ debugGatherer()
read values from table in the text.}
\item{.mapUnicode}{a logical value that controls whether the resulting
text is processed to map components of the form \\uxxxx to their
- appropriate Unicode representation.}
+ appropriate Unicode representation.}
+ \item{binary}{a logical vector that indicates which URIs yield binary content}
}
\details{
This is called when the libcurl engine finds sufficient
View
3  man/binaryBuffer.Rd
@@ -34,8 +34,7 @@ binaryBuffer(initialSize = 5000)
collecting the .
}
}
-\details{
-}
+
\value{
An object of class \code{RCurlBinaryBuffer} which is to be treated
as an opaque data for the most part. When passing this as the value of
View
35 man/clone.Rd
@@ -0,0 +1,35 @@
+\name{clone}
+\alias{clone}
+\alias{clone,ANY-method}
+\alias{clone,CURLHandle-method}
+\alias{clone,environment-method}
+\alias{clone,CFILE-method}
+\title{Clone/duplicate an object}
+\description{
+ This is a generic function and methods for making a copy of an
+ object such as a curl handle, C-level pointer to a file, etc.
+}
+\usage{
+clone(x, ...)
+}
+\arguments{
+ \item{x}{the object to be cloned.}
+ \item{\dots}{additional parameters for methods}
+}
+\value{
+ Typically, an object of the same class and \dQuote{value}
+ as the input - \code{x}.
+}
+\author{
+Duncan Temple Lang
+}
+
+\seealso{
+ \code{\link{dupCurlHandle}}
+}
+\examples{
+ h = getCurlHandle(verbose = TRUE)
+ other = dupCurlHandle(h)
+ curlSetOpt(curl = h, verbose = FALSE)
+}
+\keyword{programming}
View
3  man/complete.Rd
@@ -20,7 +20,8 @@ complete(obj, ...)
\item{\dots}{additional arguments intended to be used by specific methods.}
}
\value{
-
+ The value is typically not of interest, but rather the side effect
+ of processing the pending requests.
}
\references{
\url{http://curl.haxx.se}, specifically the multi interface of libcurl.
View
2  man/curlPerform.Rd
@@ -56,8 +56,6 @@ curlMultiPerform(curl, multiple = TRUE)
in subsequent uses of the curl handle (\code{curl}).
}
}
-\details{
-}
\value{
A integer value indicating the status of the request.
This should be 0 as other errors will generate
View
4 man/enums.Rd
@@ -62,7 +62,7 @@ The actual constants are not exported, but are defined within
the package. So we can use them with code such as
\code{RCurl:::CURLINFO_DATA_IN}.
}
-\usage{}
-\value{}
+%\usage{}
+%\value{}
\author{Duncan Temple Lang}
\keyword{programming}
View
4 man/fileUpload.Rd
@@ -58,7 +58,5 @@ fileUpload(filename = character(), contents = character(), contentType = charact
\seealso{
\code{\link{postForm}}
}
-\examples{
-
-}
+%\examples{}
\keyword{IO}
View
1  man/getBinaryURL.Rd
@@ -48,7 +48,6 @@ getBinaryURL(url, ..., .opts = list(), curl = getCurlHandle(), .buf = binaryBuff
\value{
A "raw" vector.
}
-\references{}
\author{Duncan Temple Lang}
\seealso{
\code{\link{getURL}}
View
30 man/getCurlErrorClassNames.Rd
@@ -0,0 +1,30 @@
+\name{getCurlErrorClassNames}
+\alias{getCurlErrorClassNames}
+\title{Retrieve names of all curl error classes}
+\description{
+ This function returns the names of all of the
+ error classes that curl can raise as a result
+ of a request. You can use these names
+ in calls to \code{tryCatch}
+ to identify the class of the error for which you
+ want to provide an error handler.
+}
+\usage{
+getCurlErrorClassNames()
+}
+\value{
+ A character vector
+}
+\references{
+ libcurl documentation
+}
+\author{
+Duncan Temple Lang
+}
+\seealso{
+ \code{\link[base]{tryCatch}}
+ \code{\link{curlPerform}} and higher-level functions
+ for making requests.
+}
+%\examples{}
+\keyword{programming}
View
7 man/getCurlHandle.Rd
@@ -19,12 +19,13 @@
\usage{
getCurlHandle(..., .opts = NULL, .encoding = integer(), .defaults = getOption("RCurlOptions"))
dupCurlHandle(curl, ..., .opts = NULL, .encoding = integer())
-getCurlMultiHandle()
+getCurlMultiHandle(..., .handles = list(...))
}
\arguments{
\item{curl}{the existing curl handle that is to be duplicated}
\item{...}{a named list of curl options to set after the handle has
- been created.}
+ been created. For \code{getCurlMultiHandle}, these values are
+ invidivual curl handle objects, created via \code{getCurlHandle} or \code{dupCurlHandle}. }
\item{.opts}{a named list or \code{CURLOptions} object identifying the
curl options for the handle. These and the \code{...} arguments are
used after the handle has been created.}
@@ -42,6 +43,8 @@ getCurlMultiHandle()
\item{.defaults}{a collection of default values taken from R's
global/session options. This is a parameter so that one can override
it if necessary.}
+ \item{.handles}{a list of curl handle objects that are used as the
+ individual request handles within the multi-asynchronous requests}
}
\details{
These functions create C-level data structures.
View
8 man/getURIAsynchronous.Rd
@@ -29,10 +29,10 @@
with a value of \code{FALSE} for \code{async}.
}
\usage{
-getURIAsynchronous(url, ..., .opts = list(), write = multiTextGatherer(url),
+getURIAsynchronous(url, ..., .opts = list(), write = NULL,
curl = getCurlHandle(),
multiHandle = getCurlMultiHandle(), perform = Inf,
- .encoding = integer())
+ .encoding = integer(), binary = rep(NA, length(url)))
}
\arguments{
\item{url}{a character vector identifying the URIs to download.}
@@ -72,7 +72,9 @@ getURIAsynchronous(url, ..., .opts = list(), write = multiTextGatherer(url),
the HTTP response to determine the encoding. This argument is used
when such information is erroneous and the caller knows the correct
encoding.
- }
+ }
+ \item{binary}{a logical vector identifying whether each URI has binary
+ content or simple text.}
}
\details{
This uses \code{\link{curlMultiPerform}}
View
4 man/getURL.Rd
@@ -109,9 +109,7 @@ getURLContent(url, ..., curl = getCurlHandle(.opts = .opts), .encoding = NA,
\item{isHTTP}{a logical value that indicates whether the request an
HTTP request. This is used when determining how to process the response.}
}
-\details{
-
-}
+%\details{}
\value{
If no value is supplied for \code{write},
the result is the text that is the HTTP response.
View
4 man/httpPUT.Rd
@@ -3,6 +3,8 @@
\alias{httpPOST}
\alias{httpGET}
\alias{httpDELETE}
+\alias{httpHEAD}
+\alias{httpOPTIONS}
\title{Simple high-level functions for HTTP PUT and DELETE}
\description{
These two functions are simple, high-level functions
@@ -18,6 +20,8 @@ httpPUT(url, content, ..., curl = getCurlHandle())
httpPOST(url, ..., curl = getCurlHandle())
httpDELETE(url, ..., curl = getCurlHandle())
httpGET(url, ..., curl = getCurlHandle())
+httpHEAD(url, ..., curl = getCurlHandle())
+httpOPTIONS(url, ..., curl = getCurlHandle())
}
\arguments{
\item{url}{the URL of the server to which the HTTP request is to be
View
2  man/postForm.Rd
@@ -1,5 +1,6 @@
\name{postForm}
\alias{postForm}
+\alias{.postForm}
\alias{getForm}
\title{Submit an HTML form}
\description{
@@ -15,6 +16,7 @@ postForm(uri, ..., .params = list(), .opts = curlOptions(url = uri),
curl = getCurlHandle(), style = 'HTTPPOST',
.encoding = integer(), binary = NA, .checkParams = TRUE,
.contentEncodeFun = curlEscape)
+.postForm(curl, .opts, .params, style = 'HTTPPOST')
getForm(uri, ..., .params = character(), .opts = list(), curl = getCurlHandle(),
.encoding = integer(), binary = NA, .checkParams = TRUE)
}
Please sign in to comment.
Something went wrong with that request. Please try again.