Skip to content

Commit 9989461

Browse files
authored
Add ProxyConfig new from ProxyOptions & TLS info (#421)
1 parent 9d67050 commit 9989461

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

include/aws/http/proxy.h

+15
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,21 @@ struct aws_http_proxy_config *aws_http_proxy_config_new_from_proxy_options(
506506
struct aws_allocator *allocator,
507507
const struct aws_http_proxy_options *options);
508508

509+
/**
510+
* Create a persistent proxy configuration from non-persistent proxy options.
511+
*
512+
* @param allocator memory allocator to use
513+
* @param options http proxy options to source proxy configuration from
514+
* @param is_tls_connection tls connection info of the main connection to determine connection_type
515+
* when the connection_type is legacy.
516+
* @return
517+
*/
518+
AWS_HTTP_API
519+
struct aws_http_proxy_config *aws_http_proxy_config_new_from_proxy_options_with_tls_info(
520+
struct aws_allocator *allocator,
521+
const struct aws_http_proxy_options *proxy_options,
522+
bool is_tls_connection);
523+
509524
/**
510525
* Clones an existing proxy configuration. A refactor could remove this (do a "move" between the old and new user
511526
* data in the one spot it's used) but that should wait until we have better test cases for the logic where this

source/proxy_connection.c

+16-5
Original file line numberDiff line numberDiff line change
@@ -1125,12 +1125,12 @@ static int s_aws_http_client_connect_via_tunneling_proxy(
11251125

11261126
static enum aws_http_proxy_connection_type s_determine_proxy_connection_type(
11271127
enum aws_http_proxy_connection_type proxy_connection_type,
1128-
const struct aws_tls_connection_options *tls_options) {
1128+
bool is_tls_connection) {
11291129
if (proxy_connection_type != AWS_HPCT_HTTP_LEGACY) {
11301130
return proxy_connection_type;
11311131
}
11321132

1133-
if (tls_options != NULL) {
1133+
if (is_tls_connection) {
11341134
return AWS_HPCT_HTTP_TUNNEL;
11351135
} else {
11361136
return AWS_HPCT_HTTP_FORWARD;
@@ -1184,7 +1184,7 @@ static int s_connect_proxy(const struct aws_http_client_connection_options *opti
11841184
}
11851185

11861186
enum aws_http_proxy_connection_type proxy_connection_type =
1187-
s_determine_proxy_connection_type(options->proxy_options->connection_type, options->tls_options);
1187+
s_determine_proxy_connection_type(options->proxy_options->connection_type, options->tls_options != NULL);
11881188

11891189
switch (proxy_connection_type) {
11901190
case AWS_HPCT_HTTP_FORWARD:
@@ -1398,7 +1398,7 @@ struct aws_http_proxy_config *aws_http_proxy_config_new_from_connection_options(
13981398
return s_aws_http_proxy_config_new(
13991399
allocator,
14001400
options->proxy_options,
1401-
s_determine_proxy_connection_type(options->proxy_options->connection_type, options->tls_options));
1401+
s_determine_proxy_connection_type(options->proxy_options->connection_type, options->tls_options != NULL));
14021402
}
14031403

14041404
struct aws_http_proxy_config *aws_http_proxy_config_new_from_manager_options(
@@ -1410,7 +1410,8 @@ struct aws_http_proxy_config *aws_http_proxy_config_new_from_manager_options(
14101410
return s_aws_http_proxy_config_new(
14111411
allocator,
14121412
options->proxy_options,
1413-
s_determine_proxy_connection_type(options->proxy_options->connection_type, options->tls_connection_options));
1413+
s_determine_proxy_connection_type(
1414+
options->proxy_options->connection_type, options->tls_connection_options != NULL));
14141415
}
14151416

14161417
struct aws_http_proxy_config *aws_http_proxy_config_new_tunneling_from_proxy_options(
@@ -1431,6 +1432,16 @@ struct aws_http_proxy_config *aws_http_proxy_config_new_from_proxy_options(
14311432
return s_aws_http_proxy_config_new(allocator, proxy_options, proxy_options->connection_type);
14321433
}
14331434

1435+
struct aws_http_proxy_config *aws_http_proxy_config_new_from_proxy_options_with_tls_info(
1436+
struct aws_allocator *allocator,
1437+
const struct aws_http_proxy_options *proxy_options,
1438+
bool is_tls_connection) {
1439+
AWS_FATAL_ASSERT(proxy_options != NULL);
1440+
1441+
return s_aws_http_proxy_config_new(
1442+
allocator, proxy_options, s_determine_proxy_connection_type(proxy_options->connection_type, is_tls_connection));
1443+
}
1444+
14341445
struct aws_http_proxy_config *aws_http_proxy_config_new_clone(
14351446
struct aws_allocator *allocator,
14361447
const struct aws_http_proxy_config *proxy_config) {

0 commit comments

Comments
 (0)