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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/promises": "^1.4",
"guzzlehttp/psr7": "^1.8.4|^2.1.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still required inside GuzzleTracingMiddleware, but so is GuzzleHttp\Exception\RequestException, which we do not require. Hence people need to require composer require guzzlehttp/guzzle already, so removing it is fine imo.

"jean85/pretty-package-versions": "^1.5|^2.0.4",
"php-http/async-client-implementation": "^1.0",
"php-http/client-common": "^1.5|^2.0",
"php-http/discovery": "^1.11, <1.15",
"php-http/discovery": "^1.15",
"php-http/httplug": "^1.1|^2.0",
"php-http/message": "^1.5",
"psr/http-factory": "^1.0",
"psr/http-message-implementation": "^1.0",
"psr/http-factory-implementation": "^1.0",
"psr/log": "^1.0|^2.0|^3.0",
"symfony/options-resolver": "^3.4.43|^4.4.30|^5.0.11|^6.0",
"symfony/polyfill-php80": "^1.17"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.19|3.4.*",
"guzzlehttp/psr7": "^1.8.4|^2.1.1",
"http-interop/http-factory-guzzle": "^1.0",
"monolog/monolog": "^1.6|^2.0|^3.0",
"nikic/php-parser": "^4.10.3",
Expand Down
4 changes: 2 additions & 2 deletions src/Integration/RequestFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sentry\Integration;

use GuzzleHttp\Psr7\ServerRequest;
use Http\Discovery\Psr17Factory;
use Psr\Http\Message\ServerRequestInterface;

/**
Expand All @@ -22,6 +22,6 @@ public function fetchRequest(): ?ServerRequestInterface
return null;
}

return ServerRequest::fromGlobals();
return (new Psr17Factory())->createServerRequestFromGlobals();
}
}
17 changes: 14 additions & 3 deletions src/Integration/RequestIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Sentry\Integration;

use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\UploadedFileInterface;
use Sentry\Event;
Expand Down Expand Up @@ -50,7 +49,7 @@ final class RequestIntegration implements IntegrationInterface
'never' => 0,
'small' => self::REQUEST_BODY_SMALL_MAX_CONTENT_LENGTH,
'medium' => self::REQUEST_BODY_MEDIUM_MAX_CONTENT_LENGTH,
'always' => -1,
'always' => \PHP_INT_MAX,
];

/**
Expand Down Expand Up @@ -224,7 +223,19 @@ private function captureRequestBody(Options $options, ServerRequestInterface $re
return $requestData;
}

$requestBody = Utils::copyToString($request->getBody(), self::MAX_REQUEST_BODY_SIZE_OPTION_TO_MAX_LENGTH_MAP[$maxRequestBodySize]);
$requestBody = '';
$maxLength = self::MAX_REQUEST_BODY_SIZE_OPTION_TO_MAX_LENGTH_MAP[$maxRequestBodySize];

if (0 < $maxLength) {
$stream = $request->getBody();
while (0 < $maxLength && !$stream->eof()) {
if ('' === $buffer = $stream->read(min($maxLength, self::REQUEST_BODY_MEDIUM_MAX_CONTENT_LENGTH))) {
break;
}
$requestBody .= $buffer;
$maxLength -= \strlen($buffer);
}
}

if ('application/json' === $request->getHeaderLine('Content-Type')) {
try {
Expand Down