| 1 |
test_that("roundtrip large data", { |
| 2 |
skip_if_not_installed('httpuv') |
| 3 |
skip_if_not_installed('webutils') |
| 4 |
bindata <- serialize(rnorm(1e5), NULL) |
| 5 |
input_url <- 'https://fakeserver.org:99/my/endpoint' |
| 6 |
handle <- curl::new_handle(url = input_url) |
| 7 |
handle_setheaders(handle, 'Foobar' = 'testtest') |
| 8 |
curl::handle_setform(handle, data = curl::form_data(bindata, "application/octet-stream")) |
| 9 |
formdata <- curl::curl_echo(handle = handle) |
| 10 |
expect_identical(formdata$url, input_url) |
| 11 |
expect_identical(formdata$path, '/my/endpoint') |
| 12 |
expect_identical(formdata$method, 'POST') |
| 13 |
expect_identical(formdata$headers[['foobar']], 'testtest') |
| 14 |
expect_identical(formdata$headers[['host']], "fakeserver.org:99") |
| 15 |
out <- webutils::parse_http(formdata$body, formdata$content_type) |
| 16 |
expect_identical(out$data$value, bindata) |
| 17 |
}) |