-
Notifications
You must be signed in to change notification settings - Fork 84
Closed
Labels
featurea feature request or enhancementa feature request or enhancement
Milestone
Description
GET requests can handle multi-value parameters, although there is no defined standard on how to do it. httr2 currently supports multi-value parameters when you define them explicitly as separate arguments:
request("example.com") |>
req_url_query(foo = 1, foo = 2) |>
req_dry_run()
#> GET /?foo=1&foo=2 HTTP/1.1
#> Host: example.com?foo=1&foo=2
#> User-Agent: httr2/0.2.3 r-curl/5.1.0 libcurl/8.3.0
#> Accept: */*
#> Accept-Encoding: deflate, gzipBut it would be nice if you could pass multi-value parameters as vectors and have httr2 do the work of forming the url with multiple entries for the parameter(s):
# desired behaviour
request("example.com") |>
req_url_query(foo = c(1, 2)) |>
req_dry_run()
#> GET /?foo=1&foo=2 HTTP/1.1
#> Host: example.com?foo=1&foo=2
#> User-Agent: httr2/0.2.3 r-curl/5.1.0 libcurl/8.3.0
#> Accept: */*
#> Accept-Encoding: deflate, gzipI could see the other common form of multi-value parameters being handled via I():
# desired behaviour
request("example.com") |>
req_url_query(foo = I(c(1, 2))) |>
req_dry_run()
#> GET /?foo=1,2 HTTP/1.1
#> Host: example.com?foo=1,2
#> User-Agent: httr2/0.2.3 r-curl/5.1.0 libcurl/8.3.0
#> Accept: */*
#> Accept-Encoding: deflate, gzipReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancement