Honor proxy server timeout with one second buffer

This commit is contained in:
2023-07-06 17:15:53 +02:00
parent 0f40dcb5db
commit de3fcf8fc3
4 changed files with 6 additions and 2 deletions

@ -399,8 +399,9 @@ int proxy_init(proxy_ctx_t **proxy_ptr, http_req *req, http_res *res, http_statu
if (!retry)
return -1;
// honor server timeout with one second buffer
if (!proxy->initialized || sock_has_pending(&proxy->proxy, SOCK_DONTWAIT) != 0 || srv_error ||
(proxy->http_timeout != 0 && (clock_micros() - proxy->proxy.ts_last) >= proxy->http_timeout))
(proxy->http_timeout != 0 && (clock_micros() - proxy->proxy.ts_last_send) >= proxy->http_timeout - 1000000))
{
if (proxy->initialized)
proxy_close(proxy);