Skip to content
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ Example config:
'timeout' => 3,
// the token must match 'upload.token' config in XHGui
'token' => 'token',
// verify option to disable ssl verification, defaults to true if unspecified.
'verify' => true,
),
```

Expand Down
6 changes: 5 additions & 1 deletion src/Saver/UploadSaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ final class UploadSaver implements SaverInterface
private $url;
/** @var int */
private $timeout;
/** @var bool */
private $verify;

public function __construct($url, $token, $timeout)
public function __construct($url, $token, $timeout, $verify)
{
$this->url = $url;
if ($token) {
$this->url .= '?&token=' . $token;
}

$this->timeout = $timeout;
$this->verify = $verify;
}

public function isSupported()
Expand Down Expand Up @@ -64,6 +67,7 @@ private function submit($url, $payload)
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_SSL_VERIFYPEER => $this->verify,
));
if (!$res) {
$error = curl_errno($ch) ? curl_error($ch) : '';
Expand Down
8 changes: 7 additions & 1 deletion src/SaverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ public static function create($saveHandler, Config $config)
'url' => null,
'token' => null,
'timeout' => 3,
'verify' => true,
);
$userConfig = isset($config['save.handler.upload']) && is_array($config['save.handler.upload']) ? $config['save.handler.upload'] : array();
$saverConfig = array_merge($defaultConfig, $userConfig);
$saver = new Saver\UploadSaver($saverConfig['url'] ?: $saverConfig['uri'], $saverConfig['token'], $saverConfig['timeout']);
$saver = new Saver\UploadSaver(
$saverConfig['url'] ?: $saverConfig['uri'],
$saverConfig['token'],
$saverConfig['timeout'],
$saverConfig['verify']
);
break;

case Profiler::SAVER_STACK:
Expand Down
Loading