Skip to content

Commit 9378dbe

Browse files
tsmgeekSergeyYegorchievRicardo Branco
authored
Feature - add compression support (#1)
* Added option for compress request payload * Add compression into $defaultOptions --------- Co-authored-by: Sergіy Yegorchev <s.yegorchev@svitla.com> Co-authored-by: Ricardo Branco <ricardo.branco@xtremepush.com>
1 parent 2c7f60d commit 9378dbe

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/SparkPost/SparkPost.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class SparkPost
4141
'version' => 'v1',
4242
'async' => true,
4343
'debug' => false,
44-
'retries' => 0
44+
'retries' => 0,
45+
'compression' => false,
4546
];
4647

4748
/**
@@ -186,6 +187,12 @@ public function buildRequestValues($method, $uri, $payload, $headers)
186187

187188
// old form-feed workaround now removed
188189
$body = json_encode($body);
190+
191+
if (!empty($this->options['compression']) && $this->options['compression'] === true) {
192+
$headers['Content-Encoding'] = 'gzip';
193+
$body = gzencode($body);
194+
}
195+
189196
return [
190197
'method' => $method,
191198
'url' => $url,

0 commit comments

Comments
 (0)