Skip to content
Open
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: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
22 changes: 8 additions & 14 deletions R/check-mac.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
42 changes: 15 additions & 27 deletions R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hasn't worked for a while; will be resolved by #2640.


# 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",
Expand Down
6 changes: 2 additions & 4 deletions R/run-source.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ hadley
http
https
httr
httr2
hunspell
importFrom
initialising
Expand Down