Skip to content

Commit

Permalink
Add test for seeking
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Aug 9, 2023
1 parent 68e84e0 commit 810576b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/upload.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ curl_upload <- function(file, url, verbose = TRUE, reuse = TRUE, ...) {
}
}
return(buf)
}, seekfunction = function(offset){
seek(con, where = offset)
}, forbid_reuse = !isTRUE(reuse), verbose = verbose, ...)
if(!is.na(infilesize)){
handle_setopt(h, infilesize_large = infilesize)
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-seek.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
context("Seek")

test_that("Seeking works after redirect",{
skip_on_cran()
str <- paste(letters, collapse = '')
tmp <- tempfile()
writeBin(str, tmp)
url <- httpbin('/redirect-to?url=/put&status_code=307')
req <- curl::curl_upload(tmp, url, verbose = FALSE)
headers <- curl::parse_headers(req$headers, multiple = TRUE)
expect_length(headers, 2)
expect_equal(req$status_code, 200)
content <- jsonlite::fromJSON(rawToChar(req$content))$data
expect_equal(content, str)
})

0 comments on commit 810576b

Please sign in to comment.