Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* `oauth_flow_auth_code()` now correctly uses the same redirect URI for both authorization and token requests when using the default localhost redirect URL (@pedrobtz, #829).
* `last_response_json()` now works with content-types that end with `+json`,
e.g., `application/problem+json` (@cgiachalis, #782).
* `req_body_form()` now creates a valid empty request body when no parameters
are provided (@arcresu, #836).

# httr2 1.2.2

Expand Down
2 changes: 1 addition & 1 deletion R/req-body.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ req_body_form <- function(
check_request(.req)

dots <- multi_dots(..., .multi = .multi)
data <- modify_list(.req$body$data, !!!dots)
data <- modify_list(.req$body$data %||% list(), !!!dots)
req_body(.req, data = data, type = "form")
}

Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-req-body.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ test_that("form data is unobufcated", {
expect_equal(rawToChar(req$options$postfields), 'x=x&y=y')
})

test_that("empty form data gives a valid request", {
req <- request_test() |>
req_body_form() |>
req_body_apply()
expect_equal(req$body$data, list())
})

# req_body_multipart() ---------------------------------------------------------

test_that("can send named elements as multipart", {
Expand Down
Loading