diff --git a/DESCRIPTION b/DESCRIPTION index 359386744..ce69d9016 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,7 +17,7 @@ Depends: R (>= 4.1) Imports: cli (>= 3.0.0), - curl (>= 6.2.1), + curl (>= 6.4.0), glue, lifecycle, magrittr, diff --git a/NEWS.md b/NEWS.md index d1a86cc62..2d86514af 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # httr2 (development version) +* URL construction is now powered by `curl::curl_modify_url()`, and hence now (correctly) escapes the `path` component (#732). This means that `req_url_path()` now can only affect the path component of the URL, not the query params or fragment. * Redacted headers are no longer serialized to disk. This is important since it makes it harder to accidentally leak secrets to files on disk, but comes at a cost: you can longer perform such requests that have been saved and reloaded (#721). * New `req_get_method()` and `req_get_body()` allow you to do some limited prediction of what a request _will_ do when it's performed (#718). * Functions that capture interrutps (like `req_perform_parallel()` and friends) are now easier to escape if they're called inside a loop: you can press Ctrl + C twice to guarantee an exit (#1810). diff --git a/R/resp-url.R b/R/resp-url.R index 42c67850b..e486153a2 100644 --- a/R/resp-url.R +++ b/R/resp-url.R @@ -9,7 +9,8 @@ #' @export #' @examples #' resp <- request(example_url()) |> -#' req_url_path("/get?hello=world") |> +#' req_url_path("/get") |> +#' req_url_query(hello = "world") |> #' req_perform() #' #' resp |> resp_url() diff --git a/R/url.R b/R/url.R index 94bf3a752..56e6c0d86 100644 --- a/R/url.R +++ b/R/url.R @@ -24,7 +24,7 @@ url_parse <- function(url, base_url = NULL) { check_string(url) check_string(base_url, allow_null = TRUE) - curl <- curl::curl_parse_url(url, baseurl = base_url, decode = FALSE) + curl <- curl::curl_parse_url(url, baseurl = base_url) parsed <- list( scheme = curl$scheme, @@ -267,44 +267,21 @@ url_build <- function(url) { stop_input_type(url, "a parsed URL") } - if (!is.null(url$query)) { - query <- url_query_build(url$query) + if (length(url$query) == 0) { + query <- "" } else { - query <- NULL + query <- I(url_query_build(url$query)) } - if (is.null(url$username) && is.null(url$password)) { - user_pass <- NULL - } else if (is.null(url$username) && !is.null(url$password)) { - cli::cli_abort("Cannot set url {.arg password} without {.arg username}.") - } else if (!is.null(url$username) && is.null(url$password)) { - user_pass <- paste0(url$username, "@") - } else { - user_pass <- paste0(url$username, ":", url$password, "@") - } - - if (!is.null(user_pass) || !is.null(url$hostname) || !is.null(url$port)) { - authority <- paste0(user_pass, url$hostname) - if (!is.null(url$port)) { - authority <- paste0(authority, ":", url$port) - } - } else { - authority <- NULL - } - - if (is.null(url$path) || !startsWith(url$path, "/")) { - url$path <- paste0("/", url$path) - } - - prefix <- function(prefix, x) if (!is.null(x)) paste0(prefix, x) - paste0( - url$scheme, - if (!is.null(url$scheme)) ":", - if (!is.null(url$scheme) || !is.null(authority)) "//", - authority, - url$path, - prefix("?", query), - prefix("#", url$fragment) + curl::curl_modify_url( + scheme = url$scheme, + host = url$hostname, + user = url$username, + password = url$password, + port = url$port, + path = url$path, + query = query, + fragment = url$fragment ) } diff --git a/man/resp_url.Rd b/man/resp_url.Rd index 8ad65fc65..4d248f4c3 100644 --- a/man/resp_url.Rd +++ b/man/resp_url.Rd @@ -32,7 +32,8 @@ resp_url_queries(resp) } \examples{ resp <- request(example_url()) |> - req_url_path("/get?hello=world") |> + req_url_path("/get") |> + req_url_query(hello = "world") |> req_perform() resp |> resp_url() diff --git a/revdep/README.md b/revdep/README.md index 2685ff18d..057d28255 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -1,10 +1,19 @@ # Revdeps -## Failed to check (3) +## Failed to check (1) -|package |version |error |warning |note | -|:----------|:-------|:-----|:-------|:----| -|GeoTox |? | | | | -|insight |? | | | | -|parameters |? | | | | +|package |version |error |warning |note | +|:------------|:-------|:-----|:-------|:----| +|arcgisplaces |0.1.2 |1 | | | + +## New problems (6) + +|package |version |error |warning |note | +|:-------------|:-------|:------|:-------|:----| +|[atrrr](problems.md#atrrr)|0.1.0 |__+1__ | | | +|[httptest2](problems.md#httptest2)|1.1.0 |__+1__ | | | +|[osmapiR](problems.md#osmapir)|0.2.3 |__+2__ | | | +|[planscorer](problems.md#planscorer)|0.0.2 |__+1__ | | | +|[spanishoddata](problems.md#spanishoddata)|0.2.0 |__+1__ | | | +|[tidyllm](problems.md#tidyllm)|0.3.4 |__+1__ | | | diff --git a/revdep/cran.md b/revdep/cran.md index 6a7754e14..5040b19ba 100644 --- a/revdep/cran.md +++ b/revdep/cran.md @@ -1,13 +1,34 @@ ## revdepcheck results -We checked 201 reverse dependencies (200 from CRAN + 1 from Bioconductor), comparing R CMD check results across CRAN and dev versions of this package. +We checked 221 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. - * We saw 0 new problems - * We failed to check 2 packages + * We saw 6 new problems + * We failed to check 1 packages Issues with CRAN packages are summarised below. +### New problems +(This reports the first line of each new failure) + +* atrrr + checking tests ... ERROR + +* httptest2 + checking tests ... ERROR + +* osmapiR + checking examples ... ERROR + checking tests ... ERROR + +* planscorer + checking tests ... ERROR + +* spanishoddata + checking tests ... ERROR + +* tidyllm + checking tests ... ERROR + ### Failed to check -* insight (NA) -* parameters (NA) +* arcgisplaces (NA) diff --git a/revdep/failures.md b/revdep/failures.md index 7448c0baf..31cc80a6c 100644 --- a/revdep/failures.md +++ b/revdep/failures.md @@ -1,187 +1,78 @@ -# GeoTox +# arcgisplaces
-* Version: NA +* Version: 0.1.2 * GitHub: NA -* Source code: https://github.com/cran/GeoTox -* Number of recursive dependencies: 143 +* Source code: https://github.com/cran/arcgisplaces +* Date/Publication: 2025-04-10 16:20:02 UTC +* Number of recursive dependencies: 42 -Run `revdepcheck::cloud_details(, "GeoTox")` for more info +Run `revdepcheck::cloud_details(, "arcgisplaces")` for more info
-## Error before installation - -### Devel - -``` - - - - - - -``` -### CRAN - -``` - - - - - - -``` -# insight - -
- -* Version: 1.1.0 -* GitHub: https://github.com/easystats/insight -* Source code: https://github.com/cran/insight -* Date/Publication: 2025-03-01 23:10:06 UTC -* Number of recursive dependencies: 425 - -Run `revdepcheck::cloud_details(, "insight")` for more info - -
- -## Error before installation - -### Devel - -``` -* using log directory ‘/tmp/workdir/insight/new/insight.Rcheck’ -* using R version 4.3.1 (2023-06-16) -* using platform: x86_64-pc-linux-gnu (64-bit) -* R was compiled by - gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 - GNU Fortran (Ubuntu 13.2.0-23ubuntu4) 13.2.0 -* running under: Ubuntu 24.04.1 LTS -* using session charset: UTF-8 -* using option ‘--no-manual’ -* checking for file ‘insight/DESCRIPTION’ ... OK -... - When sourcing ‘insight.R’: -Error: function 'cholmod_factor_ldetA' not provided by package 'Matrix' -Execution halted - - ‘display.Rmd’ using ‘UTF-8’... OK - ‘export.Rmd’ using ‘UTF-8’... OK - ‘insight.Rmd’ using ‘UTF-8’... failed -* checking re-building of vignette outputs ... OK -* DONE -Status: 3 ERRORs, 1 NOTE - - - - - -``` -### CRAN - -``` -* using log directory ‘/tmp/workdir/insight/old/insight.Rcheck’ -* using R version 4.3.1 (2023-06-16) -* using platform: x86_64-pc-linux-gnu (64-bit) -* R was compiled by - gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 - GNU Fortran (Ubuntu 13.2.0-23ubuntu4) 13.2.0 -* running under: Ubuntu 24.04.1 LTS -* using session charset: UTF-8 -* using option ‘--no-manual’ -* checking for file ‘insight/DESCRIPTION’ ... OK -... - When sourcing ‘insight.R’: -Error: function 'cholmod_factor_ldetA' not provided by package 'Matrix' -Execution halted - - ‘display.Rmd’ using ‘UTF-8’... OK - ‘export.Rmd’ using ‘UTF-8’... OK - ‘insight.Rmd’ using ‘UTF-8’... failed -* checking re-building of vignette outputs ... OK -* DONE -Status: 3 ERRORs, 1 NOTE - - +## In both +* checking whether package ‘arcgisplaces’ can be installed ... ERROR + ``` + Installation failed. + See ‘/tmp/workdir/arcgisplaces/new/arcgisplaces.Rcheck/00install.out’ for details. + ``` - -``` -# parameters - -
- -* Version: 0.24.2 -* GitHub: https://github.com/easystats/parameters -* Source code: https://github.com/cran/parameters -* Date/Publication: 2025-03-04 14:50:06 UTC -* Number of recursive dependencies: 474 - -Run `revdepcheck::cloud_details(, "parameters")` for more info - -
- -## Error before installation +## Installation ### Devel ``` -* using log directory ‘/tmp/workdir/parameters/new/parameters.Rcheck’ -* using R version 4.3.1 (2023-06-16) -* using platform: x86_64-pc-linux-gnu (64-bit) -* R was compiled by - gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 - GNU Fortran (Ubuntu 13.2.0-23ubuntu4) 13.2.0 -* running under: Ubuntu 24.04.1 LTS -* using session charset: UTF-8 -* using option ‘--no-manual’ -* checking for file ‘parameters/DESCRIPTION’ ... OK +* installing *source* package ‘arcgisplaces’ ... +** package ‘arcgisplaces’ successfully unpacked and MD5 sums checked +** using staged installation +Using cargo 1.75.0 +Using rustc 1.75.0 (82e1608df 2023-12-21) (built from a source tarball) +Building for CRAN. +Writing `src/Makevars`. +`tools/config.R` has finished. +** libs +using C compiler: ‘gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0’ ... - • equivalence_test/equivalence-test-5.svg - Error: Test failures - Execution halted -* checking for unstated dependencies in vignettes ... OK -* checking package vignettes in ‘inst/doc’ ... OK -* checking running R code from vignettes ... OK - ‘overview_of_vignettes.Rmd’ using ‘UTF-8’... OK -* checking re-building of vignette outputs ... OK -* DONE -Status: 2 ERRORs, 2 NOTEs - - - +export CARGO_HOME=/tmp/workdir/arcgisplaces/new/arcgisplaces.Rcheck/00_pkg_src/arcgisplaces/src/.cargo && \ +export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.cargo/bin" && \ +RUSTFLAGS=" --print=native-static-libs" cargo build -j 2 --offline --lib --release --manifest-path=./rust/Cargo.toml --target-dir ./rust/target +error: package `native-tls v0.2.14` cannot be built because it requires rustc 1.80.0 or newer, while the currently active rustc version is 1.75.0 +Either upgrade to rustc 1.80.0 or newer, or use +cargo update native-tls@0.2.14 --precise ver +where `ver` is the latest version of `native-tls` supporting rustc 1.75.0 +make: *** [Makevars:28: rust/target/release/libarcgisplaces.a] Error 101 +ERROR: compilation failed for package ‘arcgisplaces’ +* removing ‘/tmp/workdir/arcgisplaces/new/arcgisplaces.Rcheck/arcgisplaces’ ``` ### CRAN ``` -* using log directory ‘/tmp/workdir/parameters/old/parameters.Rcheck’ -* using R version 4.3.1 (2023-06-16) -* using platform: x86_64-pc-linux-gnu (64-bit) -* R was compiled by - gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 - GNU Fortran (Ubuntu 13.2.0-23ubuntu4) 13.2.0 -* running under: Ubuntu 24.04.1 LTS -* using session charset: UTF-8 -* using option ‘--no-manual’ -* checking for file ‘parameters/DESCRIPTION’ ... OK +* installing *source* package ‘arcgisplaces’ ... +** package ‘arcgisplaces’ successfully unpacked and MD5 sums checked +** using staged installation +Using cargo 1.75.0 +Using rustc 1.75.0 (82e1608df 2023-12-21) (built from a source tarball) +Building for CRAN. +Writing `src/Makevars`. +`tools/config.R` has finished. +** libs +using C compiler: ‘gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0’ ... - • equivalence_test/equivalence-test-5.svg - Error: Test failures - Execution halted -* checking for unstated dependencies in vignettes ... OK -* checking package vignettes in ‘inst/doc’ ... OK -* checking running R code from vignettes ... OK - ‘overview_of_vignettes.Rmd’ using ‘UTF-8’... OK -* checking re-building of vignette outputs ... OK -* DONE -Status: 2 ERRORs, 2 NOTEs - - - +export CARGO_HOME=/tmp/workdir/arcgisplaces/old/arcgisplaces.Rcheck/00_pkg_src/arcgisplaces/src/.cargo && \ +export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.cargo/bin" && \ +RUSTFLAGS=" --print=native-static-libs" cargo build -j 2 --offline --lib --release --manifest-path=./rust/Cargo.toml --target-dir ./rust/target +error: package `native-tls v0.2.14` cannot be built because it requires rustc 1.80.0 or newer, while the currently active rustc version is 1.75.0 +Either upgrade to rustc 1.80.0 or newer, or use +cargo update native-tls@0.2.14 --precise ver +where `ver` is the latest version of `native-tls` supporting rustc 1.75.0 +make: *** [Makevars:28: rust/target/release/libarcgisplaces.a] Error 101 +ERROR: compilation failed for package ‘arcgisplaces’ +* removing ‘/tmp/workdir/arcgisplaces/old/arcgisplaces.Rcheck/arcgisplaces’ ``` diff --git a/revdep/problems.md b/revdep/problems.md index 9a2073633..0cfbc1224 100644 --- a/revdep/problems.md +++ b/revdep/problems.md @@ -1 +1,271 @@ -*Wow, no problems at all. :)* \ No newline at end of file +# atrrr + +
+ +* Version: 0.1.0 +* GitHub: https://github.com/JBGruber/atrrr +* Source code: https://github.com/cran/atrrr +* Date/Publication: 2025-01-20 11:30:42 UTC +* Number of recursive dependencies: 96 + +Run `revdepcheck::cloud_details(, "atrrr")` for more info + +
+ +## Newly broken + +* checking tests ... ERROR + ``` + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > # This file is part of the standard setup for testthat. + > # It is recommended that you do not modify it. + > # + > # Where should you do additional test configuration? + > # Learn more about the roles of various files in: + > # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview + > # * https://testthat.r-lib.org/articles/special-files.html + ... + 33. │ └─httr2::url_build(...) + 34. │ └─curl::curl_modify_url(...) + 35. └─base::.handleSimpleError(...) + 36. └─purrr (local) h(simpleError(msg, call)) + 37. └─cli::cli_abort(...) + 38. └─rlang::abort(...) + + [ FAIL 101 | WARN 0 | SKIP 2 | PASS 68 ] + Error: Test failures + Execution halted + ``` + +# httptest2 + +
+ +* Version: 1.1.0 +* GitHub: https://github.com/nealrichardson/httptest2 +* Source code: https://github.com/cran/httptest2 +* Date/Publication: 2024-04-26 13:40:02 UTC +* Number of recursive dependencies: 53 + +Run `revdepcheck::cloud_details(, "httptest2")` for more info + +
+ +## Newly broken + +* checking tests ... ERROR + ``` + Running ‘spelling.R’ + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > library(testthat) + > test_check("httptest2") + Loading required package: httptest2 + [ FAIL 2 | WARN 0 | SKIP 2 | PASS 237 ] + + ══ Skipped tests (2) ═══════════════════════════════════════════════════════════ + ... + 9. │ └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo)) + 10. ├─r %>% req_body_file(file_to_upload) %>% req_perform() + 11. └─httr2::req_perform(.) + 12. └─httptest2 (local) mock(req) + 13. └─httptest2:::stop_request(req) + 14. └─rlang::abort(out, mockfile = req$mockfile, class = "httptest2_request") + + [ FAIL 2 | WARN 0 | SKIP 2 | PASS 237 ] + Error: Test failures + Execution halted + ``` + +# osmapiR + +
+ +* Version: 0.2.3 +* GitHub: https://github.com/ropensci/osmapiR +* Source code: https://github.com/cran/osmapiR +* Date/Publication: 2025-04-15 08:50:02 UTC +* Number of recursive dependencies: 64 + +Run `revdepcheck::cloud_details(, "osmapiR")` for more info + +
+ +## Newly broken + +* checking examples ... ERROR + ``` + Running examples in ‘osmapiR-Ex.R’ failed + The error most likely occurred in: + + > ### Name: osm_get_changesets + > ### Title: Get changesets + > ### Aliases: osm_get_changesets + > + > ### ** Examples + > + > chaset <- osm_get_changesets(changeset_id = 137595351, include_discussion = TRUE) + ... + 5. └─httr2:::resp_failure_cnd(req, resp, error_call = error_call) + 6. ├─rlang::catch_cnd(...) + 7. │ ├─rlang::eval_bare(...) + 8. │ ├─base::tryCatch(...) + 9. │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers) + 10. │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]]) + 11. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler) + 12. │ └─base::force(expr) + 13. └─rlang::abort(...) + Execution halted + ``` + +* checking tests ... ERROR + ``` + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > # This file is part of the standard setup for testthat. + > # It is recommended that you do not modify it. + > # + > # Where should you do additional test configuration? + > # Learn more about the roles of various files in: + > # * https://r-pkgs.org/tests.html + > # * https://testthat.r-lib.org/reference/test_package.html#special-files + ... + 10. │ └─rlang::eval_bare(expr, quo_get_env(quo)) + 11. └─osmapiR::osm_set_preferences_user(all_prefs = preferences) + 12. └─httr2::req_perform(req) + 13. └─httptest2 (local) mock(req) + 14. └─httptest2:::stop_request(req) + 15. └─rlang::abort(out, mockfile = req$mockfile, class = "httptest2_request") + + [ FAIL 8 | WARN 0 | SKIP 13 | PASS 1760 ] + Error: Test failures + Execution halted + ``` + +# planscorer + +
+ +* Version: 0.0.2 +* GitHub: https://github.com/christopherkenny/planscorer +* Source code: https://github.com/cran/planscorer +* Date/Publication: 2024-09-24 14:50:02 UTC +* Number of recursive dependencies: 81 + +Run `revdepcheck::cloud_details(, "planscorer")` for more info + +
+ +## Newly broken + +* checking tests ... ERROR + ``` + Running ‘spelling.R’ + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > # This file is part of the standard setup for testthat. + > # It is recommended that you do not modify it. + > # + > # Where should you do additional test configuration? + > # Learn more about the roles of various files in: + > # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview + ... + 3. │ └─httr2:::check_response(resp) + 4. │ └─httr2:::is_response(resp) + 5. └─httr2::req_perform(req) + 6. └─httptest2 (local) mock(req) + 7. └─httptest2:::stop_request(req) + 8. └─rlang::abort(out, mockfile = req$mockfile, class = "httptest2_request") + + [ FAIL 1 | WARN 0 | SKIP 0 | PASS 4 ] + Error: Test failures + Execution halted + ``` + +# spanishoddata + +
+ +* Version: 0.2.0 +* GitHub: https://github.com/rOpenSpain/spanishoddata +* Source code: https://github.com/cran/spanishoddata +* Date/Publication: 2025-06-15 23:20:02 UTC +* Number of recursive dependencies: 162 + +Run `revdepcheck::cloud_details(, "spanishoddata")` for more info + +
+ +## Newly broken + +* checking tests ... ERROR + ``` + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > # This file is part of the standard setup for testthat. + > # It is recommended that you do not modify it. + > # + > # Where should you do additional test configuration? + > # Learn more about the roles of various files in: + > # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview + > # * https://testthat.r-lib.org/articles/special-files.html + ... + Error in ``$<-`(`*tmp*`, "remote_file_size_mb", value = numeric(0))`: Assigned data `round(files_table$file_size_bytes/1024^2, 2)` must be compatible with existing data. + x Existing data has 1872 rows. + x Assigned data has 0 rows. + i Only vectors of size 1 are recycled. + Caused by error in `vectbl_recycle_rhs_rows()`: + ! Can't recycle input of size 0 to size 1872. + + [ FAIL 10 | WARN 10 | SKIP 1 | PASS 7 ] + Error: Test failures + Execution halted + ``` + +# tidyllm + +
+ +* Version: 0.3.4 +* GitHub: https://github.com/edubruell/tidyllm +* Source code: https://github.com/cran/tidyllm +* Date/Publication: 2025-03-27 11:40:01 UTC +* Number of recursive dependencies: 124 + +Run `revdepcheck::cloud_details(, "tidyllm")` for more info + +
+ +## Newly broken + +* checking tests ... ERROR + ``` + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > # This file is part of the standard setup for testthat. + > # It is recommended that you do not modify it. + > # + > # Where should you do additional test configuration? + > # Learn more about the roles of various files in: + > # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview + > # * https://testthat.r-lib.org/articles/special-files.html + ... + ── Failure ('test_api_ollama.R:59:3'): ollama_embedding function constructs a correct request and dry runs it ── + Names of `dry_run` ('method', 'path', 'body', 'headers') don't match 'method', 'path', 'headers' + ── Failure ('test_api_openai.R:17:3'): openai function constructs a correct request and dry runs it ── + Names of `dry_run` ('method', 'path', 'body', 'headers') don't match 'method', 'path', 'headers' + ── Failure ('test_api_perplexity.R:15:3'): perplexity function constructs a correct request and dry runs it ── + Names of `dry_run` ('method', 'path', 'body', 'headers') don't match 'method', 'path', 'headers' + + [ FAIL 11 | WARN 0 | SKIP 0 | PASS 269 ] + Error: Test failures + Execution halted + ``` + diff --git a/tests/testthat/_snaps/url.md b/tests/testthat/_snaps/url.md index 5b8575060..27aac4e7c 100644 --- a/tests/testthat/_snaps/url.md +++ b/tests/testthat/_snaps/url.md @@ -1,14 +1,14 @@ # can print all url details Code - url_parse("http://user:pass@example.com:80/path?a=1&b=2&c={1{2}3}#frag") + url_parse("http://user:pass@example.com:81/path?a=1&b=2&c={1{2}3}#frag") Message - http://user:pass@example.com:80/path?a=1&b=2&c=%7B1%7B2%7D3%7D#frag + http://user:pass@example.com:81/path?a=1&b=2&c=%7B1%7B2%7D3%7D#frag * scheme: http * hostname: example.com * username: user * password: pass - * port: 80 + * port: 81 * path: /path * query: * a: 1 @@ -16,14 +16,6 @@ * c: {1{2}3} * fragment: frag -# password also requires username - - Code - url_build(url) - Condition - Error in `url_build()`: - ! Cannot set url `password` without `username`. - # url_build validates its input Code diff --git a/tests/testthat/test-req-body.R b/tests/testthat/test-req-body.R index fb0e7e65c..357ea9e0b 100644 --- a/tests/testthat/test-req-body.R +++ b/tests/testthat/test-req-body.R @@ -77,7 +77,8 @@ test_that("can send file with redirect", { path <- tempfile() writeChar(str, path) - resp <- request_test("/redirect-to?url=/post&status_code=307") |> + resp <- request_test("/redirect-to") %>% + req_url_query(url = "/post", status_code = "307") |> req_body_file(path, type = "text/plain") |> req_perform() diff --git a/tests/testthat/test-resp-url.R b/tests/testthat/test-resp-url.R index 1d1a5e2ac..bc1003bb8 100644 --- a/tests/testthat/test-resp-url.R +++ b/tests/testthat/test-resp-url.R @@ -1,5 +1,6 @@ test_that("can extract url components from a response", { - resp <- req_perform(request_test("/get?a=1&b=2")) + req <- request_test("/get") %>% req_url_query(a = "1", b = "2") + resp <- req_perform(req) expect_equal(resp_url(resp), example_url("/get?a=1&b=2")) expect_equal(resp_url_path(resp), "/get") diff --git a/tests/testthat/test-url.R b/tests/testthat/test-url.R index ae39fe474..cecc931a3 100644 --- a/tests/testthat/test-url.R +++ b/tests/testthat/test-url.R @@ -9,12 +9,11 @@ test_that("can round trip urls", { "http://google.com/", "http://google.com/path", "http://google.com/path?a=1&b=2", - "http://google.com:80/path?a=1&b=2", - "http://google.com:80/path?a=1&b=2#frag", - "http://google.com:80/path?a=1&b=2&c=%7B1%7B2%7D3%7D#frag", - "http://user@google.com:80/path?a=1&b=2", - "http://user:pass@google.com:80/path?a=1&b=2", - "svn+ssh://my.svn.server/repo/trunk" + "http://google.com:81/path?a=1&b=2", + "http://google.com:81/path?a=1&b=2#frag", + "http://google.com:81/path?a=1&b=2&c=%7B1%7B2%7D3%7D#frag", + "http://user@google.com:81/path?a=1&b=2", + "http://user:pass@google.com:81/path?a=1&b=2" ) expect_equal(map(urls, \(url) url_build(url_parse(url))), urls) @@ -30,23 +29,17 @@ test_that("can parse relative urls", { test_that("can print all url details", { expect_snapshot( - url_parse("http://user:pass@example.com:80/path?a=1&b=2&c={1{2}3}#frag") + url_parse("http://user:pass@example.com:81/path?a=1&b=2&c={1{2}3}#frag") ) }) -test_that("password also requires username", { - url <- url_parse("http://username:pwd@example.com") - url$username <- NULL - expect_snapshot(url_build(url), error = TRUE) -}) - test_that("url_build validates its input", { expect_snapshot(url_build("abc"), error = TRUE) }) -test_that("decodes query params but not paths", { +test_that("decodes params and paths", { url <- url_parse("http://example.com/a%20b?q=a%20b") - expect_equal(url$path, "/a%20b") + expect_equal(url$path, "/a b") expect_equal(url$query$q, "a b") }) @@ -97,11 +90,15 @@ test_that("can accept query as a string or list", { expect_equal(url_modify(url, query = list()), "http://test/") }) -test_that("automatically escapes query components", { +test_that("encodes params and paths", { expect_equal( url_modify("https://example.com", query = list(q = "a b")), "https://example.com/?q=a%20b" ) + expect_equal( + url_modify("https://example.com", path = "a b"), + "https://example.com/a%20b" + ) }) test_that("checks various query formats", {