Skip to content

Commit

Permalink
Throw error if timeout < 1ms.
Browse files Browse the repository at this point in the history
Closes #175
  • Loading branch information
hadley committed Dec 31, 2014
1 parent edfc4dc commit 14c11a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
and we can't guess the type from the extension, we now assume that it's
`application/octet-stream` (#181).

* Throw error if `timeout()` is less than 1 ms (#175).

# httr 0.6.0

## New features
Expand Down
5 changes: 5 additions & 0 deletions R/timeout.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Set maximum request time.
#'
#' @param seconds number of seconds to wait for a response until giving up.
#' Can not be less than 1 ms.
#' @family config
#' @export
#' @examples
Expand All @@ -9,5 +10,9 @@
#' GET("http://httpbin.org/delay/1", timeout(2))
#' }
timeout <- function(seconds) {
if (seconds < 0.001) {
stop("Timeout cannot be less than 1 ms", call. = FALSE)
}

config(timeout.ms = seconds * 1000)
}

0 comments on commit 14c11a0

Please sign in to comment.