Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Fix empty request for HTTP connection exception #49924

Merged
merged 1 commit into from
Jan 31, 2024
Merged
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
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
Loading