Skip to content

Commit

Permalink
Extend curl_opts to allow multiple data elements
Browse files Browse the repository at this point in the history
Fixes #509
  • Loading branch information
hadley committed Sep 4, 2024
1 parent 33635e6 commit 233bf2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/curl.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ curl_data <- function(x, binary = FALSE, raw = FALSE) {
}

# Format described at <http://docopt.org>
curl_opts <- "Usage: curl [<url>] [-H <header> ...] [options] [<url>]
curl_opts <- "Usage: curl [<url>] [-H <header> ...] [-d <data> ...] [options] [<url>]
--basic (IGNORED)
--compressed (IGNORED)
--digest (IGNORED)
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-curl.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down

0 comments on commit 233bf2a

Please sign in to comment.