Skip to content

Commit

Permalink
http_async_client: add curl_follow_redirect parameter
Browse files Browse the repository at this point in the history
- add curl_follow_redirect mod parameter to set CURLOPT_FOLLOWLOCATION
  to tell libcurl to follow 3xx responses.
- write the doc in doc subfolder for the curl_follow_redirect param
  • Loading branch information
gled-rs committed Mar 27, 2021
1 parent ec3f98b commit 14a3996
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/modules/http_async_client/doc/http_async_client_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,26 @@ modparam("http_async_client", "curl_verbose", 1)
</programlisting>
</example>
</section>
<section>
<title><varname>curl_follow_redirect</varname> (integer)</title>
<para>
If defined to a non-zero value, will tell curl to follow HTTP 3xx redirects.
</para>
<para>
<emphasis>
Default value is 0 (disabled).
</emphasis>
</para>
<example>
<title>Set <varname>curl_follow_redirect</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("http_async_client", "curl_follow_redirect", 1)
...
</programlisting>
</example>
</section>

<section>
<title><varname>memory_manager</varname> (string)</title>
<para>
Expand Down
2 changes: 2 additions & 0 deletions src/modules/http_async_client/http_async_client_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ int tls_version = 0; // Use default SSL version in HTTPS requests (see curl/curl
int tls_verify_host = 1; // By default verify host in HTTPS requests
int tls_verify_peer = 1; // By default verify peer in HTTPS requests
int curl_verbose = 0;
int curl_follow_redirect = 0;
char* tls_client_cert = NULL; // client SSL certificate path, defaults to NULL
char* tls_client_key = NULL; // client SSL certificate key path, defaults to NULL
char* tls_ca_path = NULL; // certificate authority dir path, defaults to NULL
Expand Down Expand Up @@ -150,6 +151,7 @@ static param_export_t params[]={
{"tls_verify_host", INT_PARAM, &tls_verify_host},
{"tls_verify_peer", INT_PARAM, &tls_verify_peer},
{"curl_verbose", INT_PARAM, &curl_verbose},
{"curl_follow_redirect", INT_PARAM, &curl_follow_redirect},
{"tls_client_cert", PARAM_STRING, &tls_client_cert},
{"tls_client_key", PARAM_STRING, &tls_client_key},
{"tls_ca_path", PARAM_STRING, &tls_ca_path},
Expand Down
3 changes: 3 additions & 0 deletions src/modules/http_async_client/http_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ int new_request(str *query, http_m_params_t *query_params, http_multi_cbe_t cb,
curl_easy_setopt(cell->easy, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(cell->easy, CURLOPT_DEBUGFUNCTION, debug_cb);
}
if (curl_follow_redirect) {
curl_easy_setopt(cell->easy, CURLOPT_FOLLOWLOCATION, 1L);
}
curl_easy_setopt(cell->easy, CURLOPT_ERRORBUFFER, cell->error);
curl_easy_setopt(cell->easy, CURLOPT_PRIVATE, cell);
curl_easy_setopt(cell->easy, CURLOPT_SSL_VERIFYPEER, cell->params.tls_verify_peer);
Expand Down
1 change: 1 addition & 0 deletions src/modules/http_async_client/http_multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern stat_var *errors;
extern stat_var *timeouts;
extern int tls_version;
extern int curl_verbose;
extern int curl_follow_redirect;

void set_curl_mem_callbacks(void);
int init_http_multi();
Expand Down

0 comments on commit 14a3996

Please sign in to comment.