From 233bf2a2462a137d1ad7603fe7cfa2d7d3c9a5e1 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 4 Sep 2024 12:22:19 +0100 Subject: [PATCH] Extend `curl_opts` to allow multiple data elements Fixes #509 --- R/curl.R | 2 +- tests/testthat/test-curl.R | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/R/curl.R b/R/curl.R index 5a7710a0..cc5cef56 100644 --- a/R/curl.R +++ b/R/curl.R @@ -197,7 +197,7 @@ curl_data <- function(x, binary = FALSE, raw = FALSE) { } # Format described at -curl_opts <- "Usage: curl [] [-H
...] [options] [] +curl_opts <- "Usage: curl [] [-H
...] [-d ...] [options] [] --basic (IGNORED) --compressed (IGNORED) --digest (IGNORED) diff --git a/tests/testthat/test-curl.R b/tests/testthat/test-curl.R index b3302991..225983a4 100644 --- a/tests/testthat/test-curl.R +++ b/tests/testthat/test-curl.R @@ -34,6 +34,13 @@ test_that("captures key components of call", { expect_equal(curl_args("curl 'http://example.com' --verbose")$`--verbose`, TRUE) }) +test_that("can accept multiple data arguments", { + expect_equal( + curl_args("curl https://example.com -d x=1 -d y=2")$`--data`, + c("x=1", "y=2") + ) +}) + test_that("can handle line breaks", { expect_equal( curl_args("curl 'http://example.com' \\\n -H 'A: 1' \\\n -H 'B: 2'")$`--header`,