Skip to content

Commit

Permalink
update branch with main
Browse files Browse the repository at this point in the history
Merge branch 'main' into url_parse

# Conflicts:
#	paws.common/R/custom_s3.R
#	paws.common/R/url.R
  • Loading branch information
DyfanJones committed Jan 4, 2025
2 parents bb5e1ec + fa6eb07 commit ae9d22e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
16 changes: 7 additions & 9 deletions paws.common/R/custom_s3.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ dns_compatible_bucket_name <- function(bucket) {
}

move_bucket_to_host <- function(url, bucket) {
url$host <- paste0(bucket, ".", url$host)
url$path <- gsub("/\\{Bucket\\}", "", url$path)
url[["host"]] <- paste0(bucket, ".", url[["host"]])
url[["path"]] <- gsub("/\\{Bucket\\}", "", url$path)

if (url$path == "") {
url$path <- "/"
if (url[["path"]] == "") {
url[["path"]] <- "/"
}

return(url)
}

Expand Down Expand Up @@ -114,7 +113,7 @@ update_endpoint_for_s3_config <- function(request) {
}

if (is_access_point(bucket_name)) {
request$http_request$url$host <- get_access_point_endpoint(bucket_name)
request$http_request$url[["host"]] <- get_access_point_endpoint(bucket_name)
request$http_request$url <- remove_bucket_from_url(request$http_request$url)
return(request)
}
Expand Down Expand Up @@ -442,16 +441,15 @@ set_request_url <- function(original_endpoint,
final_endpoint_components <- parse_url(original_endpoint)
scheme <- final_endpoint_components$scheme
if (use_new_scheme) {
scheme <- new_endpoint_components$scheme
scheme <- new_endpoint_components[["scheme"]]
}
path <- (
if (final_endpoint_components[["path"]] == "/") "" else final_endpoint_components[["path"]]
)
final_endpoint_components[["host"]] <- new_endpoint_components$host
final_endpoint_components[["scheme"]] <- scheme
final_endpoint_components[["path"]] <- path
final_endpoint <- build_url(final_endpoint_components)
return(final_endpoint)
return(build_url(final_endpoint_components))
}

################################################################################
Expand Down
2 changes: 1 addition & 1 deletion paws.common/R/net.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ new_http_request <- function(method, url, body = NULL, close = FALSE, connect_ti
proto_minor = 1,
header = header,
body = body,
host = u$host,
host = u[["host"]],
close = close,
connect_timeout = connect_timeout,
timeout = timeout,
Expand Down
6 changes: 3 additions & 3 deletions paws.common/R/request.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ sanitize_host_for_header <- function(http_request) {
host <- get_host(http_request)
port <- get_port(host)
if (port != "" && is_default_port(http_request$url$scheme, port)) {
http_request$host <- strip_port(host)
http_request[["host"]] <- strip_port(host)
}
return(http_request)
}

# Return the host from an HTTP request.
get_host <- function(http_request) {
host <- http_request$host
host <- http_request[["host"]]
if (host == "") {
host <- http_request$url$host
host <- http_request$url[["host"]]
}
return(host)
}
Expand Down
6 changes: 3 additions & 3 deletions paws.common/R/signer_v4.R
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,10 @@ build_canonical_headers <- function(ctx, header, ignored_headers) {
header_values <- c()
for (key in headers) {
if (key == "host") {
if (ctx$request$host != "") {
header_value <- paste0("host:", ctx$request$host)
if (ctx$request[["host"]] != "") {
header_value <- paste0("host:", ctx$request[["host"]])
} else {
header_value <- paste0("host:", ctx$request$url$host)
header_value <- paste0("host:", ctx$request$url[["host"]])
}
} else {
value <- ctx$signed_header_vals[[key]]
Expand Down

0 comments on commit ae9d22e

Please sign in to comment.