Skip to content
Merged
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
9 changes: 8 additions & 1 deletion source/proxy_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ static int s_connect_proxy_via_env_variable(const struct aws_http_client_connect
proxy_options.connection_type = options->proxy_ev_settings->connection_type;
if (proxy_options.connection_type == AWS_HPCT_HTTP_LEGACY) {
if (options->tls_options) {
/* Use Tunneling when main connection use TLS. */
/* Use tunneling when main connection use TLS. */
proxy_options.connection_type = AWS_HPCT_HTTP_TUNNEL;
} else {
/* Use forwarding proxy when main connection use clear text. */
Expand All @@ -1212,6 +1212,9 @@ static int s_connect_proxy_via_env_variable(const struct aws_http_client_connect
};
proxy_options.proxy_strategy = aws_http_proxy_strategy_new_basic_auth(options->allocator, &config);
}
} else {
success = true;
goto done;
}
struct aws_http_client_connection_options copied_options = *options;
copied_options.proxy_options = &proxy_options;
Expand All @@ -1223,6 +1226,10 @@ static int s_connect_proxy_via_env_variable(const struct aws_http_client_connect
aws_tls_connection_options_clean_up(&default_tls_connection_options);
aws_http_proxy_strategy_release(proxy_options.proxy_strategy);
aws_uri_clean_up(&proxy_uri);
if (success && !found) {
/* Successfully, but no envrionment variable found. Connect without proxy */
return aws_http_client_connect_internal(options, NULL);
}
return success ? AWS_OP_SUCCESS : AWS_OP_ERR;
}

Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ add_test_case(h2_client_get_remote_settings)
add_test_case(server_new_destroy)
add_test_case(connection_setup_shutdown)
add_test_case(connection_setup_shutdown_tls)
add_test_case(connection_setup_shutdown_proxy_setting_on_ev_not_found)
add_test_case(connection_h2_prior_knowledge)
add_test_case(connection_h2_prior_knowledge_not_work_with_tls)
add_test_case(connection_customized_alpn)
Expand Down
37 changes: 37 additions & 0 deletions tests/test_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,43 @@ static int s_test_connection_setup_shutdown_tls(struct aws_allocator *allocator,
}
AWS_TEST_CASE(connection_setup_shutdown_tls, s_test_connection_setup_shutdown_tls);

static int s_test_connection_setup_shutdown_proxy_setting_on_ev_not_found(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
struct tester_options options = {
.alloc = allocator,
.no_connection = true,
};
struct tester tester;
ASSERT_SUCCESS(s_tester_init(&tester, &options));
struct aws_http_client_connection_options client_options = AWS_HTTP_CLIENT_CONNECTION_OPTIONS_INIT;
struct proxy_env_var_settings proxy_ev_settings;
AWS_ZERO_STRUCT(proxy_ev_settings);
proxy_ev_settings.env_var_type = AWS_HPEV_ENABLE;
client_options.proxy_ev_settings = &proxy_ev_settings;

s_client_connection_options_init_tester(&client_options, &tester);
tester.client_options = client_options;

tester.server_connection_num = 0;
tester.client_connection_num = 0;
ASSERT_SUCCESS(aws_http_client_connect(&tester.client_options));

/* Wait for server & client connections to finish setup */
tester.wait_client_connection_num = 1;
tester.wait_server_connection_num = 1;
ASSERT_SUCCESS(s_tester_wait(&tester, s_tester_connection_setup_pred));

release_all_client_connections(&tester);
release_all_server_connections(&tester);
ASSERT_SUCCESS(s_tester_wait(&tester, s_tester_connection_shutdown_pred));

ASSERT_SUCCESS(s_tester_clean_up(&tester));
return AWS_OP_SUCCESS;
}
AWS_TEST_CASE(
connection_setup_shutdown_proxy_setting_on_ev_not_found,
s_test_connection_setup_shutdown_proxy_setting_on_ev_not_found);

static int s_test_connection_h2_prior_knowledge(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
struct tester_options options = {
Expand Down