Skip to content

Commit

Permalink
Swap order for isRejected checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Sep 3, 2023
1 parent 8914fec commit ca9222f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Internal/EventInvoker.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ private function invoke(Request $request, \Closure $closure): void

public function requestStart(Request $request): void
{
if (self::isRejected($request)) {
throw new \Error('Request has been rejected by the server. Use a new request for retries.');
}

$previousPhase = self::getPhase($request);
if ($previousPhase !== Phase::Unprocessed) {
throw new \Error('Invalid request phase transition from ' . $previousPhase->name . ' to Blocked');
}

if (self::isRejected($request)) {
throw new \Error('Request has been rejected by the server. Use a new request for retries.');
}

$this->requestPhase[$request] = Phase::Blocked;

$this->invoke($request, fn (EventListener $eventListener) => $eventListener->requestStart($request));
Expand Down Expand Up @@ -120,15 +120,15 @@ public function push(Request $request): void

public function requestHeaderStart(Request $request, Stream $stream): void
{
if (self::isRejected($request)) {
throw new \Error('Request has been rejected by the server. Use a new request for retries.');
}

$previousPhase = self::getPhase($request);
if ($previousPhase !== Phase::Connected && $previousPhase !== Phase::Push) {
throw new \Error('Invalid request phase transition from ' . $previousPhase->name . ' to RequestHeaders');
}

if (self::isRejected($request)) {
throw new \Error('Request has been rejected by the server. Use a new request for retries.');
}

$this->requestPhase[$request] = Phase::RequestHeaders;

$this->invoke($request, fn (EventListener $eventListener) => $eventListener->requestHeaderStart($request, $stream));
Expand Down

0 comments on commit ca9222f

Please sign in to comment.