These allow one to easily view the option's description within the IDE.
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\RequestOptions;
use ParagonIE\ConstantTime\Hex;
use Psr\Http\Client\ClientExceptionInterface;
use wcf\system\exception\NamedUserException;
{
if (!$this->httpClient) {
$this->httpClient = HttpFactory::makeClient([
- 'timeout' => 5,
+ RequestOptions::TIMEOUT => 5,
]);
}
use GuzzleHttp\Exception\TransferException;
use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\RequestOptions;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\SystemException;
use wcf\system\io\File;
// download image
try {
$client = HttpFactory::makeClient([
- 'timeout' => 10,
+ RequestOptions::TIMEOUT => 10,
]);
$request = new Request('GET', $url, [
'via' => '1.1 wsc',
namespace wcf\system\background\job;
use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\RequestOptions;
use wcf\data\user\rank\UserRank;
use wcf\data\user\rank\UserRankEditor;
use wcf\system\io\HttpFactory;
$extension = \pathinfo(Url::parse($rank->rankImage)['path'], \PATHINFO_EXTENSION);
if (\in_array($extension, ['gif', 'png', 'jpg', 'jpeg', 'svg', 'webp'])) {
$http = HttpFactory::makeClient([
- 'timeout' => 10,
+ RequestOptions::TIMEOUT => 10,
]);
$imageDest = WCF_DIR . UserRank::RANK_IMAGE_DIR . $rank->rankID . '-rankImage.' . $extension;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
+use GuzzleHttp\RequestOptions;
/**
* Factory for HTTP Clients.
public static function makeClient(array $options = [])
{
$defaults = [
- 'proxy' => PROXY_SERVER_HTTP,
- 'headers' => [],
- 'timeout' => 60,
+ RequestOptions::PROXY => PROXY_SERVER_HTTP,
+ RequestOptions::HEADERS => [],
+ RequestOptions::TIMEOUT => 60,
];
foreach ($defaults as $key => $value) {
}
$foundUserAgent = false;
- foreach ($options['headers'] as $headerName => $value) {
+ foreach ($options[RequestOptions::HEADERS] as $headerName => $value) {
if (\strtolower($headerName) === 'user-agent') {
$foundUserAgent = true;
break;
}
}
if (!$foundUserAgent) {
- $options['headers']['user-agent'] = self::getDefaultUserAgent();
+ $options[RequestOptions::HEADERS]['user-agent'] = self::getDefaultUserAgent();
}
return new Client($options);
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\RequestOptions;
use wcf\system\io\AtomicWriter;
use wcf\system\io\HttpFactory;
use wcf\system\SingletonFactory;
{
$this->http = HttpFactory::makeClient([
'base_uri' => 'https://fonts.woltlab.com/',
- 'timeout' => 10,
+ RequestOptions::TIMEOUT => 10,
]);
}
use GuzzleHttp\Exception\TooManyRedirectsException;
use GuzzleHttp\Exception\TransferException;
use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\RequestOptions;
use ParagonIE\ConstantTime\Hex;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
$options = [
// No overall timeout
- 'timeout' => 0,
- 'connect_timeout' => $this->options['timeout'],
- 'read_timeout' => $this->options['timeout'],
- 'allow_redirects' => [
+ RequestOptions::TIMEOUT => 0,
+ RequestOptions::CONNECT_TIMEOUT => $this->options['timeout'],
+ RequestOptions::READ_TIMEOUT => $this->options['timeout'],
+ RequestOptions::ALLOW_REDIRECTS => [
'max' => $this->options['maxDepth'],
'track_redirects' => true,
'on_redirect' => $redirectHandler,
],
];
if (isset($this->options['maxLength'])) {
- $options['stream'] = true;
+ $options[RequestOptions::STREAM] = true;
}
if (isset($this->options['auth'])) {
- $options['auth'] = [
+ $options[RequestOptions::AUTH] = [
$this->options['auth']['username'],
$this->options['auth']['password'],
];