diff --git a/bin/elasticurl/main.c b/bin/elasticurl/main.c index 20b4b5eaf..a6dfad8ac 100644 --- a/bin/elasticurl/main.c +++ b/bin/elasticurl/main.c @@ -451,12 +451,6 @@ static void s_on_signing_complete(struct aws_http_message *request, int error_co static void s_on_client_connection_setup(struct aws_http_connection *connection, int error_code, void *user_data) { struct elasticurl_ctx *app_ctx = user_data; - if (app_ctx->required_http_version) { - if (aws_http_connection_get_version(connection) != app_ctx->required_http_version) { - fprintf(stderr, "Error. The requested HTTP version, %s, is not supported by the peer.", app_ctx->alpn); - exit(1); - } - } if (error_code) { fprintf(stderr, "Connection failed with error %s\n", aws_error_debug_str(error_code)); @@ -467,6 +461,13 @@ static void s_on_client_connection_setup(struct aws_http_connection *connection, return; } + if (app_ctx->required_http_version) { + if (aws_http_connection_get_version(connection) != app_ctx->required_http_version) { + fprintf(stderr, "Error. The requested HTTP version, %s, is not supported by the peer.", app_ctx->alpn); + exit(1); + } + } + app_ctx->connection = connection; app_ctx->request = s_build_http_request(app_ctx);