Skip to content

Commit

Permalink
Handle empty path in AWS_CONTAINER_CREDENTIALS_FULL_URI
Browse files Browse the repository at this point in the history
URI paths are allowed to be empty, but for HTTP requests we need to
replace empty paths with `/`. This fix allows examples like:

    export AWS_CONTAINER_CREDENTIALS_FULL_URI=http://127.0.0.1:9911

to work.

Signed-off-by: James Bornholt <[email protected]>
  • Loading branch information
jamesbornholt committed Jan 22, 2024
1 parent 7911fa2 commit 01462fa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/credentials_provider_default_chain.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ static struct aws_credentials_provider *s_aws_credentials_provider_new_ecs_or_im
goto clean_up;
}

struct aws_byte_cursor path_and_query = uri.path_and_query;
if (path_and_query.len == 0) {
path_and_query = aws_byte_cursor_from_c_str("/");
}

struct aws_credentials_provider_ecs_options ecs_options = {
.shutdown_options = *shutdown_options,
.bootstrap = bootstrap,
.host = uri.host_name,
.path_and_query = uri.path_and_query,
.path_and_query = path_and_query,
.tls_ctx = aws_byte_cursor_eq_c_str_ignore_case(&(uri.scheme), "HTTPS") ? tls_ctx : NULL,
.auth_token = auth_token_cursor,
.port = uri.port,
Expand Down

0 comments on commit 01462fa

Please sign in to comment.