-
-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/2.1.2' into develop
* release/2.1.2: meta: Update changelog meta: Changelog 2.1.2 Skip integrations not bound to the current client and fetch their options from it (#861) Do not set the transaction attribute of the event when in CLI (#864) Added OXID eShop to the list of 3rd party integrations (#860) Fix error thrown when function name is missing in the stacktrace frame (#823) Fix sending of GZIP-compressed requests when the enable_compression option is on (#857) # Conflicts: # CHANGELOG.md # tests/ClientBuilderTest.php
- Loading branch information
Showing
22 changed files
with
281 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sentry\HttpClient\Plugin; | ||
|
||
use Http\Client\Common\Plugin as PluginInterface; | ||
use Http\Message\Encoding\GzipEncodeStream; | ||
use Http\Promise\Promise as PromiseInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
|
||
/** | ||
* This plugin encodes the request body by compressing it with Gzip. | ||
* | ||
* @author Stefano Arlandini <sarlandini@alice.it> | ||
*/ | ||
final class GzipEncoderPlugin implements PluginInterface | ||
{ | ||
/** | ||
* Constructor. | ||
* | ||
* @throws \RuntimeException If the zlib extension is not enabled | ||
*/ | ||
public function __construct() | ||
{ | ||
if (!\extension_loaded('zlib')) { | ||
throw new \RuntimeException('The "zlib" extension must be enabled to use this plugin.'); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handleRequest(RequestInterface $request, callable $next, callable $first): PromiseInterface | ||
{ | ||
$requestBody = $request->getBody(); | ||
|
||
if ($requestBody->isSeekable()) { | ||
$requestBody->rewind(); | ||
} | ||
|
||
$request = $request->withHeader('Content-Encoding', 'gzip'); | ||
$request = $request->withBody(new GzipEncodeStream($requestBody)); | ||
|
||
return $next($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.