Skip to content

Commit

Permalink
Fix empty request for HTTP connection exception (#49924)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints authored Jan 31, 2024
1 parent d65ea42 commit 8206d96
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Illuminate/Http/Client/PendingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ public function send(string $method, string $url, array $options = [])
}
});
} catch (ConnectException $e) {
$this->dispatchConnectionFailedEvent();
$this->dispatchConnectionFailedEvent(new Request($e->getRequest()));

throw new ConnectionException($e->getMessage(), 0, $e);
}
Expand Down Expand Up @@ -1010,7 +1010,7 @@ protected function makePromise(string $method, string $url, array $options = [])
})
->otherwise(function (OutOfBoundsException|TransferException $e) {
if ($e instanceof ConnectException) {
$this->dispatchConnectionFailedEvent();
$this->dispatchConnectionFailedEvent(new Request($e->getRequest()));
}

return $e instanceof RequestException && $e->hasResponse() ? $this->populateResponse($this->newResponse($e->getResponse())) : $e;
Expand Down Expand Up @@ -1405,8 +1405,7 @@ protected function dispatchRequestSendingEvent()
*/
protected function dispatchResponseReceivedEvent(Response $response)
{
if (! ($dispatcher = $this->factory?->getDispatcher()) ||
! $this->request) {
if (! ($dispatcher = $this->factory?->getDispatcher()) || ! $this->request) {
return;
}

Expand All @@ -1416,12 +1415,13 @@ protected function dispatchResponseReceivedEvent(Response $response)
/**
* Dispatch the ConnectionFailed event if a dispatcher is available.
*
* @param \Illuminate\Http\Client\Request $request
* @return void
*/
protected function dispatchConnectionFailedEvent()
protected function dispatchConnectionFailedEvent(Request $request)
{
if ($dispatcher = $this->factory?->getDispatcher()) {
$dispatcher->dispatch(new ConnectionFailed($this->request));
$dispatcher->dispatch(new ConnectionFailed($request));
}
}

Expand Down

0 comments on commit 8206d96

Please sign in to comment.