Permalink
Browse files

new version with Hadley's .postForm fn.

  • Loading branch information...
1 parent c229c26 commit 8cb23e7e0704fd1015bc3df83bafd31304c0d7c3 @duncantl duncantl committed Sep 29, 2012
View
@@ -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
@@ -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,6 +1,7 @@
import(methods)
export(getURL, getURI, postForm, getForm, getURLContent)
+export(.postForm)
export(curlGlobalInit,curlVersion)
export(curlOptions)
export(getCurlInfoConstants, getCurlOptionsConstants, listCurlOptions)
View
@@ -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
@@ -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
@@ -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
@@ -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
@@ -19,11 +19,7 @@
\source{
libcurl (see \url{http://curl.haxx.se})
}
-\references{
-}
-\seealso{
-
-}
-\examples{
-}
+%\references{}
+%\seealso{}
+%\examples{}
\keyword{datasets}
View
@@ -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}
@@ -59,7 +59,5 @@
\code{\link{curlMultiPerform}}
\code{\link{multiTextGatherer}}
}
-\examples{
-
-}
+%\examples{}
\keyword{classes}
View
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -58,7 +58,5 @@ fileUpload(filename = character(), contents = character(), contentType = charact
\seealso{
\code{\link{postForm}}
}
-\examples{
-
-}
+%\examples{}
\keyword{IO}
View
@@ -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}}
@@ -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}
Oops, something went wrong.

0 comments on commit 8cb23e7

Please sign in to comment.