feat: add a timeout option for http client (#2600)

This commit is contained in:
dag 2022-04-08 21:22:13 +02:00 committed by GitHub
parent 8c18c02c65
commit cce11964a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View File

@ -13,6 +13,7 @@
timezone = "UTC" timezone = "UTC"
[http] [http]
timeout = 60
useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36" useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
[cache] [cache]

View File

@ -17,6 +17,7 @@ __Notice__: If a parameter is not specified in your `config.ini.php` RSS-Bridge
The configuration file is split into sections: The configuration file is split into sections:
* [system](#system) * [system](#system)
* [http client](#http client)
* [cache](#cache) * [cache](#cache)
* [proxy](#proxy) * [proxy](#proxy)
* [authentication](#authentication) * [authentication](#authentication)
@ -25,6 +26,8 @@ The configuration file is split into sections:
_System_: This section specifies system specific parameters _System_: This section specifies system specific parameters
_Http client_: This section has http client options
_Cache_: This section is all about the caching behavior of RSS-Bridge _Cache_: This section is all about the caching behavior of RSS-Bridge
_Proxy_: This section can be used to specify a proxy server for RSS-Bridge to utilize for fetching contents _Proxy_: This section can be used to specify a proxy server for RSS-Bridge to utilize for fetching contents
@ -98,6 +101,21 @@ Allow users to disable proxy usage for specific requests.
`false` = disabled (default) `false` = disabled (default)
## Http client
This section provides the following parameters:
- timeout
- useragent
### timeout
Default network timeout.
### useragent
Default user agent.
## Authentication ## Authentication
This section provides following parameters: This section provides following parameters:

View File

@ -169,6 +169,7 @@ function getContents($url, $header = array(), $opts = array(), $returnHeader = f
} }
curl_setopt($ch, CURLOPT_USERAGENT, Configuration::getConfig('http', 'useragent')); curl_setopt($ch, CURLOPT_USERAGENT, Configuration::getConfig('http', 'useragent'));
curl_setopt($ch, CURLOPT_TIMEOUT, Configuration::getConfig('http', 'timeout'));
curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);