Skip to content

Caching error if with and the without path #840

@gaborcsardi

Description

@gaborcsardi

I.e. if the first requests write the body to file via path, and this is cached, then a second request without path fails:

From r-lib/gh#228

library(webfakes)
library(httr2)

app <- local_app_process(httpbin_app())
url <- app$url("/etag/abc123")

cache_dir <- tempfile("httr2-cache-")
dir.create(cache_dir)

make_req <- function() {
  request(url) |>
    req_cache(path = cache_dir) |>
    req_error(is_error = function(r) FALSE)
}

req_perform(make_req(), path = tempfile())
#> <httr2_response>
#> GET http://127.0.0.1:61147/etag/abc123
#> Status: 200 OK
#> Content-Type: application/json
#> Body: On disk '/var/folders/h9/6ct_py4s319fxt88dxn506l00000gp/T//RtmpkcOIVr/file9d2d9dea568' (286 bytes)

req_perform(make_req())
#> Error in `file.copy()`:
#> ! file can not be copied both 'from' and 'to'

Created on 2026-05-27 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions