File: test-echo.R

package info (click to toggle)
r-cran-curl 4.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 740 kB
  • sloc: ansic: 2,674; sh: 11; makefile: 5
file content (17 lines) | stat: -rw-r--r-- 768 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
context("echo")

test_that("roundtrip large data", {
  bindata <- serialize(rnorm(1e5), NULL)
  input_url <- 'https://fakeserver.org:99/my/endpoint'
  handle <- curl::new_handle(url = input_url)
  handle_setheaders(handle, 'Foobar' = 'testtest')
  curl::handle_setform(handle, data =  curl::form_data(bindata, "application/octet-stream"))
  formdata <- curl::curl_echo(handle = handle)
  expect_identical(formdata$url, input_url)
  expect_identical(formdata$path, '/my/endpoint')
  expect_identical(formdata$method, 'POST')
  expect_identical(formdata$headers[['foobar']], 'testtest')
  expect_identical(formdata$headers[['host']], "fakeserver.org:99")
  out <- webutils::parse_http(formdata$body, formdata$content_type)
  expect_identical(out$data$value, bindata)
})