Skip to content

Commit

Permalink
Merge pull request #18 from JKingweb/client-conf
Browse files Browse the repository at this point in the history
Restore most client configuration
  • Loading branch information
nicolus committed Feb 13, 2020
2 parents 5cd51dc + f0f3747 commit 0bcba7e
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions lib/PicoFeed/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Client
*
* @var string
*/
protected $user_agent = 'PicoFeed (https://github.com/miniflux/picoFeed)';
protected $user_agent = 'PicoFeed (https://github.com/nicolus/picoFeed)';

/**
* Real URL used (can be changed after a HTTP redirect).
Expand Down Expand Up @@ -184,7 +184,35 @@ class Client
*/
public function doRequest()
{
return $this->httpClient->get($this->url);
$opts = [
'timeout' => $this->timeout,
'allow_redirects' => ['max' => $this->max_redirects],
'headers' => ['User-Agent' => $this->user_agent],
'curl' => $this->additional_curl_options,
];
if (strlen($this->last_modified)) {
$opts['headers']['If-Modified-Since'] = $this->last_modified;
}
if (strlen($this->etag)) {
$opts['headers']['If-None-Match'] = $this->etag;
}
if (strlen($this->username)) {
$opts['auth'] = ['username' => $this->username, 'password' => (string) $this->password];
}
if (strlen($this->proxy_hostname)) {
// Proxies are assumed to be plain HTTP proxies because this is what PicoFeed historically assumed
$proxy = "http://";
if (strlen($this->proxy_username)) {
$proxy .= rawurlencode($this->proxy_username);
if (strlen($this->proxy_password)) {
$proxy .= ":" . rawurlencode($this->proxy_password);
}
$proxy .= "@";
}
$proxy .= $this->proxy_hostname . ":" . $this->proxy_port;
$opts['proxy'] = $proxy;
}
return $this->httpClient->get($this->url, $opts);
}

public function __construct(ClientInterface $httpClient = null)
Expand Down

0 comments on commit 0bcba7e

Please sign in to comment.