-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support .multi
in req_body_form()
#371
Conversation
And remove old fallback
} | ||
|
||
# Format other params | ||
dots[n == 1] <- lapply(dots[n == 1], format_query_param, error_call = error_call) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stumbled over this issue
devtools::load_all("~/GitHub/httr2/")
#> ℹ Loading httr2
data <- list(a = c("ab", "c"))
request_test("/post") %>%
req_body_form(!!!data, .multi = "comma") %>%
req_verbose(body_req = TRUE) %>%
req_perform()
#> -> POST /post HTTP/1.1
#> -> Host: 127.0.0.1:50747
#> -> User-Agent: httr2/0.2.3.9000 r-curl/5.1.0 libcurl/8.1.2
#> -> Accept: */*
#> -> Accept-Encoding: deflate, gzip
#> -> Content-Type: application/x-www-form-urlencoded
#> -> Content-Length: 9
#> ->
#> >> a=ab,c%20
#> <- HTTP/1.1 200 OK
#> <- Connection: close
#> <- Date: Fri, 10 Nov 2023 10:00:31 GMT
#> <- Content-Type: application/json
#> <- Content-Length: 457
#> <- ETag: "6dd433e5"
#> <-
#> <httr2_response>
#> POST http://127.0.0.1:50747/post
#> Status: 200 OK
#> Content-Type: application/json
#> Body: In memory (457 bytes)
Created on 2023-11-10 with reprex v2.0.2
You can see that the body is a=ab,c%20
instead of a=ab,c
because white spaces are appended.
In format_query_param()
we need to use justify = "none"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I did that in #355. Maybe that didn't get in this branch? Anyway I'll double check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No looks like a different problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ARGH you need justify = "none"
for strings and trim = TRUE
for numbers.
#Conflicts: # NEWS.md
Fixes #368