Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a timeout option for http client #2600

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.default.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
timezone = "UTC"

[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"

[cache]
Expand Down
18 changes: 18 additions & 0 deletions docs/03_For_Hosts/08_Custom_Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

* [system](#system)
* [http client](#http client)
* [cache](#cache)
* [proxy](#proxy)
* [authentication](#authentication)
Expand All @@ -25,6 +26,8 @@ The configuration file is split into sections:

_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

_Proxy_: This section can be used to specify a proxy server for RSS-Bridge to utilize for fetching contents
Expand Down Expand Up @@ -98,6 +101,21 @@ Allow users to disable proxy usage for specific requests.

`false` = disabled (default)

## Http client

This section provides the following parameters:

- timeout
- useragent

### timeout

Default network timeout.

### useragent

Default user agent.

## Authentication

This section provides following parameters:
Expand Down
1 change: 1 addition & 0 deletions lib/contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_TIMEOUT, Configuration::getConfig('http', 'timeout'));
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);

Expand Down