Skip to content
Open
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
14 changes: 4 additions & 10 deletions source/credentials_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <aws/common/string.h>
#include <aws/common/uuid.h>
#include <aws/http/connection.h>
#include <aws/http/http.h>
#include <aws/http/request_response.h>
#include <aws/http/status_code.h>
#include <aws/sdkutils/aws_profile.h>
Expand Down Expand Up @@ -299,22 +300,15 @@ struct aws_credentials *aws_parse_credentials_from_json_document(
return credentials;
}

static bool s_is_transient_network_error(int error_code) {
return error_code == AWS_ERROR_HTTP_CONNECTION_CLOSED || error_code == AWS_ERROR_HTTP_SERVER_CLOSED ||
error_code == AWS_IO_SOCKET_CLOSED || error_code == AWS_IO_SOCKET_CONNECT_ABORTED ||
error_code == AWS_IO_SOCKET_CONNECTION_REFUSED || error_code == AWS_IO_SOCKET_NETWORK_DOWN ||
error_code == AWS_IO_DNS_QUERY_FAILED || error_code == AWS_IO_DNS_NO_ADDRESS_FOR_HOST ||
error_code == AWS_IO_SOCKET_TIMEOUT || error_code == AWS_IO_TLS_NEGOTIATION_TIMEOUT ||
error_code == AWS_HTTP_STATUS_CODE_408_REQUEST_TIMEOUT;
}

enum aws_retry_error_type aws_credentials_provider_compute_retry_error_type(int response_code, int error_code) {

enum aws_retry_error_type error_type = response_code >= 400 && response_code < 500
? AWS_RETRY_ERROR_TYPE_CLIENT_ERROR
: AWS_RETRY_ERROR_TYPE_SERVER_ERROR;

if (s_is_transient_network_error(error_code)) {
// We are removing few error codes a legacy method used to assume as transient errors.
// Read PR for more information.
if (aws_http_error_code_is_retryable(error_code)) {
error_type = AWS_RETRY_ERROR_TYPE_TRANSIENT;
}

Expand Down
Loading