Skip to content

Commit

Permalink
lib-http: client: Gave request, connect and dns timeouts defaults tha…
Browse files Browse the repository at this point in the history
…t make more sense.
  • Loading branch information
stephanbosch authored and sirainen committed Feb 25, 2016
1 parent 1f1ba79 commit 5257840
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/lib-http/http-client-host.c
Expand Up @@ -118,7 +118,14 @@ static void http_client_host_lookup
memset(&dns_set, 0, sizeof(dns_set));
dns_set.dns_client_socket_path =
client->set.dns_client_socket_path;
dns_set.timeout_msecs = HTTP_CLIENT_DNS_LOOKUP_TIMEOUT_MSECS;
if (client->set.connect_timeout_msecs > 0)
dns_set.timeout_msecs = client->set.connect_timeout_msecs;
else if (client->set.request_timeout_msecs > 0)
dns_set.timeout_msecs = client->set.request_timeout_msecs;
else {
dns_set.timeout_msecs =
HTTP_CLIENT_DEFAULT_DNS_LOOKUP_TIMEOUT_MSECS;
}
(void)dns_lookup(host->name, &dns_set,
http_client_host_dns_callback, host, &host->dns_lookup);
} else {
Expand Down
5 changes: 2 additions & 3 deletions src/lib-http/http-client-private.h
Expand Up @@ -9,10 +9,9 @@
#define HTTP_DEFAULT_PORT 80
#define HTTPS_DEFAULT_PORT 443

#define HTTP_CLIENT_DNS_LOOKUP_TIMEOUT_MSECS (1000*30)
#define HTTP_CLIENT_CONNECT_TIMEOUT_MSECS (1000*30)
#define HTTP_CLIENT_CONTINUE_TIMEOUT_MSECS (1000*2)
#define HTTP_CLIENT_DEFAULT_REQUEST_TIMEOUT_MSECS (1000*60*5)
#define HTTP_CLIENT_DEFAULT_REQUEST_TIMEOUT_MSECS (1000*60*1)
#define HTTP_CLIENT_DEFAULT_DNS_LOOKUP_TIMEOUT_MSECS (1000*10)
#define HTTP_CLIENT_DEFAULT_BACKOFF_TIME_MSECS (100)
#define HTTP_CLIENT_DEFAULT_BACKOFF_MAX_TIME_MSECS (1000*60)

Expand Down
5 changes: 4 additions & 1 deletion src/lib-http/http-client.c
Expand Up @@ -142,7 +142,10 @@ struct http_client *http_client_init(const struct http_client_settings *set)
client->set.response_hdr_limits = set->response_hdr_limits;
client->set.request_absolute_timeout_msecs =
set->request_absolute_timeout_msecs;
client->set.request_timeout_msecs = set->request_timeout_msecs;
client->set.request_timeout_msecs =
set->request_timeout_msecs == 0 ?
HTTP_CLIENT_DEFAULT_REQUEST_TIMEOUT_MSECS :
set->request_timeout_msecs;
client->set.connect_timeout_msecs = set->connect_timeout_msecs;
client->set.soft_connect_timeout_msecs = set->soft_connect_timeout_msecs;
client->set.max_auto_retry_delay = set->max_auto_retry_delay;
Expand Down

0 comments on commit 5257840

Please sign in to comment.