Skip to content

Commit

Permalink
Merge branch 'main' into debug-option
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Jul 12, 2024
2 parents 2b9b3ae + 31408d4 commit 8c0edab
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# httr2 (development version)

* `req_cache()` now defaults the `debug` argument to the `httr2_cache_debug` option to make it easier to debug caching buried in other people's code (#486).
* `req_oauth_password()` now only asks for your password once (#498).
* `req_url_query()` now allows you to opt out of escaping for multi-value parameters (#404).
* `req_perform_parallel()` now works correctly with `req_cache()` (#447).
* `req_body_file()` now only opens a connection when the request actually needs data. In particular, this makes it work better with `req_perform_parallel()` (#487).
* `req_perform_parallel()` now works when downloading 0 byte files (#478)
* Corrupt `rds` files no longer cause the request to fail.
* `req_cache()` no longer fails if the `rds` files are somehow corrupted

# httr2 1.0.1

Expand Down
4 changes: 1 addition & 3 deletions R/oauth-flow-password.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ req_oauth_password <- function(req,
cache_disk = FALSE,
cache_key = username) {

password <- check_password(password)
params <- list(
client = client,
username = username,
Expand All @@ -56,12 +55,11 @@ oauth_flow_password <- function(client,
interactive = is.null(password)
)
check_string(username)
password <- check_password(password)

oauth_client_get_token(client,
grant_type = "password",
username = username,
password = password,
password = check_password(password),
scope = scope,
!!!token_params
)
Expand Down
10 changes: 3 additions & 7 deletions R/req-body.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,13 @@ req_body_apply <- function(req) {

if (type == "raw-file") {
size <- file.info(data)$size
started <- FALSE
done <- FALSE
con <- NULL
# Only open connection if needed
delayedAssign("con", file(data, "rb"))

# Leaks connection if request doesn't complete
readfunction <- function(nbytes, ...) {
if (!started) {
con <<- file(data, "rb")
started <<- TRUE
} else if (done) {
if (done) {
return(raw())
}
out <- readBin(con, "raw", nbytes)
Expand All @@ -226,7 +223,6 @@ req_body_apply <- function(req) {
seekfunction <- function(offset, ...) {
if (done) {
con <<- file(data, "rb")
started <<- TRUE
done <<- FALSE
}
seek(con, where = offset)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-req-throttle.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_that("first request isn't throttled", {

test_that("throttling causes expected average request rate", {
skip_on_cran()
skip_on_covr()
skip_on_ci()
throttle_reset()

nps <- 20
Expand Down

0 comments on commit 8c0edab

Please sign in to comment.