diff --git a/lib/SparkPost/SparkPost.php b/lib/SparkPost/SparkPost.php index 140caf7..fdd02f6 100644 --- a/lib/SparkPost/SparkPost.php +++ b/lib/SparkPost/SparkPost.php @@ -41,7 +41,8 @@ class SparkPost 'version' => 'v1', 'async' => true, 'debug' => false, - 'retries' => 0 + 'retries' => 0, + 'compression' => false, ]; /** @@ -186,6 +187,12 @@ public function buildRequestValues($method, $uri, $payload, $headers) // old form-feed workaround now removed $body = json_encode($body); + + if (!empty($this->options['compression']) && $this->options['compression'] === true) { + $headers['Content-Encoding'] = 'gzip'; + $body = gzencode($body); + } + return [ 'method' => $method, 'url' => $url,