Skip to content

Commit

Permalink
Support compress option from config
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Oct 22, 2020
1 parent 064f9e3 commit bc87a60
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ Example config:
'timeout' => 3,
// the token must match 'upload.token' config in XHGui
'token' => 'token',
// whether to gzip compress the payload
'compress' => true,
),
```

Expand Down
2 changes: 1 addition & 1 deletion src/Saver/UploadSaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UploadSaver implements SaverInterface
/** @var bool */
private $compress;

public function __construct($url, $token, $timeout, $compress = false)
public function __construct($url, $token, $timeout, $compress)
{
$this->url = $url;
if ($token) {
Expand Down
3 changes: 2 additions & 1 deletion src/SaverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ public static function create($saveHandler, array $config = array())
'uri' => null,
'token' => null,
'timeout' => 3,
'compress' => false,
);
$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['uri'], $saverConfig['token'], $saverConfig['timeout']);
$saver = new Saver\UploadSaver($saverConfig['uri'], $saverConfig['token'], $saverConfig['timeout'], $saverConfig['compress']);
break;

case Profiler::SAVER_STACK:
Expand Down

0 comments on commit bc87a60

Please sign in to comment.