Skip to content

Commit

Permalink
#20 add progress param to HttpRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Jul 9, 2018
1 parent 09ff3e4 commit aef66c1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions R/httprequest.R
Expand Up @@ -80,6 +80,7 @@ HttpRequest <- R6::R6Class(
auth = list(),
headers = list(),
handle = NULL,
progress = NULL,
payload = NULL,

print = function(x, ...) {
Expand All @@ -104,10 +105,11 @@ HttpRequest <- R6::R6Class(
cat(sprintf(" %s: %s", names(self$headers)[i],
self$headers[[i]]), sep = "\n")
}
cat(paste0(" progress: ", !is.null(self$progress)), sep = "\n")
invisible(self)
},

initialize = function(url, opts, proxies, auth, headers, handle) {
initialize = function(url, opts, proxies, auth, headers, handle, progress) {
if (!missing(url)) self$url <- url

# curl options: check for set_opts first
Expand All @@ -127,6 +129,12 @@ HttpRequest <- R6::R6Class(
if (!is.null(crul_opts$auth)) self$auth <- crul_opts$auth
if (!missing(auth)) self$auth <- auth

# progress
if (!missing(progress)) {
assert(progress, "request")
self$progress <- progress$options
}

# headers: check for set_headers first
if (!is.null(crul_opts$headers)) self$headers <- crul_opts$headers
if (!missing(headers)) self$headers <- headers
Expand All @@ -149,7 +157,7 @@ HttpRequest <- R6::R6Class(
)
rr$headers <- norm_headers(rr$headers, self$headers)
rr$options <- utils::modifyList(
rr$options, c(self$opts, self$proxies, self$auth, ...))
rr$options, c(self$opts, self$proxies, self$auth, self$progress, ...))
rr$disk <- disk
rr$stream <- stream
self$payload <- rr
Expand Down

0 comments on commit aef66c1

Please sign in to comment.