Skip to content

Commit

Permalink
Update url stripping
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbrink committed Oct 11, 2021
1 parent 04179ce commit b1da807
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/AmznSPAHttp.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private function call(string $method, string $url, array $data = [], bool $grant
}

if ($e->getCode() === 429) {
throw new RateLimitException(previous: $e);
throw new RateLimitException(previous: $e);
}

try {
Expand Down Expand Up @@ -175,8 +175,9 @@ private function setupHttp(Factory $http, bool $grantless = false): void

$this->http->beforeSending(function (Request $request) {
$url = $request->url();
$url = substr($url, 0, (strrpos($url, '?') ?: strlen($url)));

$this->config->getLogger()->debug('[AmznSPA] Pre-Request '.$request->method().' '.substr($url, 0, strrpos($url, '?')), [
$this->config->getLogger()->debug('[AmznSPA] Pre-Request '.$request->method().' '.$url, [
'unsigned_request_headers' => $this->cleanData($request->headers()),
'request_data' => $this->cleanData($request->data()),
]);
Expand Down Expand Up @@ -268,7 +269,7 @@ public function shouldReturnErrorResponse(RequestException $e): bool

private function logException(Exception $e, $method, $url)
{
$url = substr($url, 0, strrpos($url, '?'));
$url = substr($url, 0, (strrpos($url, '?') ?: strlen($url)));
$request_headers = $this->request ? $this->cleanData($this->request->headers()) : null;

$this->config->getLogger()->error('[AmznSPA] Response Error '.strtoupper($method).' '.$url.' -- '.$e->getMessage(), [
Expand Down Expand Up @@ -309,7 +310,7 @@ private function getMetadata(Response $response): MetadataSchema

private function handleResponse(Response $response, string $method, string $url): array
{
$url = substr($url, 0, strrpos($url, '?'));
$url = substr($url, 0, (strrpos($url, '?') ?: strlen($url)));

$this->config->getLogger()->debug('[AmznSPA] Response '.strtoupper($method).' '.$url, [
'response_headers' => $response->headers(),
Expand Down

0 comments on commit b1da807

Please sign in to comment.