httr2 icon indicating copy to clipboard operation
httr2 copied to clipboard

Opt out of escaping for multi-value parameters

Open asadow opened this issue 2 years ago • 1 comments

Is it possible to opt out of escaping when supplying a vector to ... in req_url_query()?

library(httr2)
x <- c("[]PCO", "[]DM")
req <- request("w") 
req |> req_url_query(x = x, .multi = "comma")
#> <httr2_request>
#> GET /w?x=%5B%5DPCO,%5B%5DDM
#> Body: empty
req |> req_url_query(x = I(x), .multi = "comma")
#> Error in `lapply()`:
#> ! Escaped query value must be a single string, not a character vector.
#> Backtrace:
#>     ▆
#>  1. └─httr2::req_url_query(req, x = I(x), .multi = "comma")
#>  2.   └─httr2:::multi_dots(..., .multi = .multi)
#>  3.     └─base::lapply(X = dots[n > 1], FUN = format_query_param)
#>  4.       └─httr2 (local) FUN(X[[i]], ...)
#>  5.         └─httr2:::check_string(x, call = error_call, arg = I("Escaped query value"))
#>  6.           └─httr2:::stop_input_type(...)
#>  7.             └─rlang::abort(message, ..., call = call, arg = arg)

Created on 2023-11-30 with reprex v2.0.2

asadow avatar Nov 30 '23 20:11 asadow

Looks like a bug.

hadley avatar Nov 30 '23 22:11 hadley