diff --git a/DESCRIPTION b/DESCRIPTION index 9f9e4ba8a..65f7adca4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -48,7 +48,7 @@ Suggests: DT (>= 0.23), foghorn (>= 1.4.2), gh (>= 1.3.0), - httr (>= 1.4.3), + httr2 (>= 1.0.0), knitr (>= 1.39), lintr (>= 3.0.0), rmarkdown (>= 2.14), diff --git a/R/check-mac.R b/R/check-mac.R index 4b3ab098d..36c9ab700 100644 --- a/R/check-mac.R +++ b/R/check-mac.R @@ -100,30 +100,24 @@ check_mac <- function( url <- "https://mac.r-project.org/macbuilder/v1/submit" - check_installed("httr") + check_installed("httr2") body <- list( - pkgfile = httr::upload_file(built_path), + pkgfile = curl::form_file(built_path), rflavor = tolower(version) ) if (length(dep_built_paths) > 0) { - uploads <- lapply(dep_built_paths, httr::upload_file) + uploads <- lapply(dep_built_paths, curl::form_file) names(uploads) <- rep("depfiles", length(uploads)) body <- append(body, uploads) } - res <- httr::POST( - url, - body = body, - headers = list( - "Content-Type" = "multipart/form-data" - ), - encode = "multipart" - ) - - httr::stop_for_status(res, task = "Uploading package") + req <- httr2::request(url) |> + httr2::req_body_multipart(!!!body) |> + httr2::req_headers(Accept = "application/json") + resp <- httr2::req_perform(req) - response_url <- httr::content(res)$url + response_url <- httr2::resp_body_json(resp)$url if (!quiet) { time <- strftime(Sys.time() + 10 * 60, "%I:%M %p") diff --git a/R/release.R b/R/release.R index 6d9adcf67..1c5e07c39 100644 --- a/R/release.R +++ b/R/release.R @@ -289,54 +289,42 @@ extract_cran_msg <- function(msg) { } upload_cran <- function(pkg, built_path, call = parent.frame()) { + check_installed("httr2") + pkg <- as.package(pkg) maint <- maintainer(pkg) comments <- cran_comments(pkg, call = call) # Initial upload --------- cli::cli_inform(c(i = "Uploading package & comments")) - check_installed("httr") - body <- list( + req <- httr2::request(cran_submission_url) + req <- httr2::req_body_multipart( + req, pkg_id = "", name = maint$name, email = maint$email, - uploaded_file = httr::upload_file(built_path, "application/x-gzip"), + uploaded_file = curl::form_file(built_path, "application/x-gzip"), comment = comments, upload = "Upload package" ) - r <- httr::POST(cran_submission_url, body = body) - - # If a 404 likely CRAN is closed for maintenance, try to get the message - if (httr::status_code(r) == 404) { - msg <- "" - try({ - r2 <- httr::GET(sub("index2", "index", cran_submission_url)) - msg <- extract_cran_msg(httr::content(r2, "text")) - }) - cli::cli_abort( - c( - "*" = "Submission failed", - "x" = msg - ), - call = call - ) - } - - httr::stop_for_status(r) - new_url <- httr::parse_url(r$url) + resp <- httr2::req_perform(req) + new_url <- httr2::url_parse(httr2::resp_url(resp)) # Confirmation ----------- cli::cli_inform(c(i = "Confirming submission")) - body <- list( + + req <- httr2::request(cran_submission_url) + req <- httr2::req_body_multipart( + req, pkg_id = new_url$query$pkg_id, name = maint$name, email = maint$email, policy_check = "1/", submit = "Submit package" ) - r <- httr::POST(cran_submission_url, body = body) - httr::stop_for_status(r) - new_url <- httr::parse_url(r$url) + + resp <- httr2::req_perform(req) + new_url <- httr2::url_parse(httr2::resp_url(resp)) if (new_url$query$submit == "1") { cli::cli_inform(c( "v" = "Package submission successful", diff --git a/R/run-source.R b/R/run-source.R index fa8adeb1d..62d13853e 100644 --- a/R/run-source.R +++ b/R/run-source.R @@ -30,14 +30,12 @@ #' } source_url <- function(url, ..., sha1 = NULL) { check_string(url) - check_installed(c("digest", "httr")) + check_installed(c("digest", "httr2")) temp_file <- file_temp() on.exit(file_delete(temp_file), add = TRUE) - request <- httr::GET(url) - httr::stop_for_status(request) - writeBin(httr::content(request, type = "raw"), temp_file) + httr2::req_perform(httr2::request(url), path = temp_file) check_sha1(temp_file, sha1) diff --git a/inst/WORDLIST b/inst/WORDLIST index 169011520..dd5374f22 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -99,6 +99,7 @@ hadley http https httr +httr2 hunspell importFrom initialising