tests/testthat/test-seek.R
raw| 1 | test_that("Seeking works after redirect",{ |
| 2 | skip_on_cran() |
| 3 | str <- paste(letters, collapse = '') |
| 4 | tmp <- tempfile() |
| 5 | writeBin(str, tmp) |
| 6 | url <- httpbin('/redirect-to?url=/put&status_code=307') |
| 7 | req <- curl::curl_upload(tmp, url, verbose = FALSE) |
| 8 | headers <- curl::parse_headers(req$headers, multiple = TRUE) |
| 9 | expect_length(headers, 2) |
| 10 | expect_equal(req$status_code, 200) |
| 11 | content <- jsonlite::fromJSON(rawToChar(req$content))$data |
| 12 | expect_equal(content, str) |
| 13 | }) |