Permalink
Browse files

Fixes for R CMD check

  • Loading branch information...
1 parent 144f0b0 commit 6b64a148d96fce4489d14edb22f2391469ae85fb @hadley committed Mar 30, 2012
Showing with 58 additions and 19 deletions.
  1. +1 −0 NAMESPACE
  2. +2 −0 R/config.r
  3. +1 −1 R/http-post.r
  4. +1 −1 R/proxy.r
  5. +8 −4 R/request.r
  6. +1 −1 R/response.r
  7. +1 −1 R/timeout.r
  8. +9 −0 R/url.r
  9. +0 −2 R/verbose.r
  10. +1 −1 man/POST.Rd
  11. +19 −0 man/modify_url.Rd
  12. +1 −1 man/response.Rd
  13. +1 −1 man/timeout.Rd
  14. +1 −1 man/use_proxy.Rd
  15. +0 −5 man/verbose.Rd
  16. +11 −0 man/with_config.Rd
View
@@ -6,6 +6,7 @@ export(DELETE)
export(GET)
export(handle)
export(HEAD)
+export(modify_url)
export(new_bin)
export(parse_url)
export(POST)
View
@@ -78,6 +78,8 @@ reset_config <- function() set_config(config(), TRUE)
#' Execute code with configuration set.
#'
#' @family ways to set configuration
+#' @inheritParams set_config
+#' @param expr code to execute under specified configuration
#' @export
with_config <- function(config = config(), expr, override = FALSE) {
stopifnot(is.config(config))
View
@@ -15,7 +15,7 @@
#'
#' b2 <- "http://httpbin.org/post"
#' POST(b2, body = list(x = "A simple text string"))
-#' POST(b2, body = list(y = fileUpload(system.file("CITATION")))
+#' POST(b2, body = list(y = fileUpload(system.file("CITATION"))))
POST <- function(url = NULL, config = list(), body = NULL, multipart = TRUE, ..., handle = NULL) {
hu <- handle_url(handle, url, ...)
make_request("POST", hu$handle, hu$url, body = body, multipart = multipart,
View
@@ -1,6 +1,6 @@
#' Use a proxy to connect to the internet.
#'
-#' @param url location of proxy
+#' @param url,port location of proxy
#' @param username,password login details for proxy, if needed
#' @family config
#' @export
View
@@ -78,7 +78,7 @@ put_request <- function(handle, url, content, opts) {
}
-post_request <- function (handle, url, body = list(), opts = list(), multipart = TRUE, encoding = integer()) {
+post_request <- function (handle, url, body = NULL, opts = list(), multipart = TRUE, encoding = integer()) {
stopifnot(is.handle(handle))
stopifnot(is.character(url), length(url) == 1)
@@ -87,7 +87,7 @@ post_request <- function (handle, url, body = list(), opts = list(), multipart =
opts$writefunction <-
getNativeSymbolInfo("R_curl_write_binary_data")$address
opts$writedata <- buffer@ref
-
+
if (is.null(body)) {
opts$post <- 1L
opts$postfieldsize <- 0L
@@ -100,14 +100,18 @@ post_request <- function (handle, url, body = list(), opts = list(), multipart =
body <- vapply(body, encode, FUN.VALUE = character(1))
body <- str_c(names(body), body, sep = "=", collapse = "&")
} else {
- body <- as.list(body)
+ charify <- function(x) {
+ if (inherits(x, "FileUploadInfo")) return(x)
+ as.character(x)
+ }
+ body <- lapply(body, charify)
stopifnot(length(names(body)) > 0)
}
# Create option list, but don't set values
opts <- curlSetOpt(curl = NULL, .opts = opts)
- style <- if (multipart) NA else 47
+ style <- if (multipart && body != "") NA else 47
.Call("R_post_form", handle$handle@ref, opts, body, TRUE,
as.integer(style), PACKAGE = "RCurl")
View
@@ -13,7 +13,7 @@
#' \item \code{text} the body of the response, as text
#' \item \code{time} request timing information
#' \item \code{config} configuration for the request
-#'
+#' }
#' @name response
NULL
View
@@ -1,6 +1,6 @@
#' Set maximum request time.
#'
-#' @param second number of seconds to wait for a response until giving up.
+#' @param seconds number of seconds to wait for a response until giving up.
#' @family config
#' @export
#' @examples
View
@@ -122,6 +122,15 @@ build_url <- function(url) {
str_c(scheme, "://", login, hostname, port, "/", path, query)
}
+#' Modify a url.
+#'
+#' Modify a url by first parsing and it then replacing components with
+#' the non-NULL arguments of this function.
+#'
+#' @export
+#' @param url the url to modify
+#' @param scheme,hostname,port,path,query,params,username,password
+#' components of the url to change
modify_url <- function(url, scheme = NULL, hostname = NULL, port = NULL, path = NULL, query = NULL, params = NULL, username = NULL, password = NULL) {
old <- parse_url(url)
View
@@ -3,8 +3,6 @@
#' A verbose connection provides much more information about the flow of
#' information between the client and server.
#'
-#' @param x a handle
-#' @param value a logical vector of length 1.
#' @family config
#' @export
#' @examples
View
@@ -48,6 +48,6 @@ POST(b, body = list(a = 1, file = fileUpload(system.file("CITATION"))))
b2 <- "http://httpbin.org/post"
POST(b2, body = list(x = "A simple text string"))
-POST(b2, body = list(y = fileUpload(system.file("CITATION")))
+POST(b2, body = list(y = fileUpload(system.file("CITATION"))))
}
View
@@ -0,0 +1,19 @@
+\name{modify_url}
+\alias{modify_url}
+\title{Modify a url.}
+\usage{
+ modify_url(url, scheme = NULL, hostname = NULL,
+ port = NULL, path = NULL, query = NULL, params = NULL,
+ username = NULL, password = NULL)
+}
+\arguments{
+ \item{url}{the url to modify}
+
+ \item{scheme,hostname,port,path,query,params,username,password}{components
+ of the url to change}
+}
+\description{
+ Modify a url by first parsing and it then replacing
+ components with the non-NULL arguments of this function.
+}
+
View
@@ -15,6 +15,6 @@
returned by the server \item \code{text} the body of the
response, as text \item \code{time} request timing
information \item \code{config} configuration for the
- request
+ request }
}
View
@@ -5,7 +5,7 @@
timeout(seconds)
}
\arguments{
- \item{second}{number of seconds to wait for a response
+ \item{seconds}{number of seconds to wait for a response
until giving up.}
}
\description{
View
@@ -6,7 +6,7 @@
password = NULL)
}
\arguments{
- \item{url}{location of proxy}
+ \item{url,port}{location of proxy}
\item{username,password}{login details for proxy, if
needed}
View
@@ -4,11 +4,6 @@
\usage{
verbose()
}
-\arguments{
- \item{x}{a handle}
-
- \item{value}{a logical vector of length 1.}
-}
\description{
A verbose connection provides much more information about
the flow of information between the client and server.
View
@@ -4,6 +4,17 @@
\usage{
with_config(config = config(), expr, override = FALSE)
}
+\arguments{
+ \item{expr}{code to execute under specified
+ configuration}
+
+ \item{config}{Settings as generated by
+ \code{\link{add_headers}}, \code{\link{set_cookies}} or
+ \code{\link{authenticate}}.}
+
+ \item{override}{if \code{TRUE}, ignore existing settings,
+ if \code{FALSE}, combine new config with old.}
+}
\description{
Execute code with configuration set.
}

0 comments on commit 6b64a14

Please sign in to comment.