Skip to content

Commit f78532c

Browse files
authored
Document 'connection failed' event (#7154)
1 parent 76272c2 commit f78532c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

http-client.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ Headers may be added to requests using the `withHeaders` method. This `withHeade
127127
])->post('http://example.com/users', [
128128
'name' => 'Taylor',
129129
]);
130-
130+
131131
You may use the `accept` method to specify the content type that your application is expecting in response to your request:
132132

133133
$response = Http::accept('application/json')->get('http://example.com/users');
134-
134+
135135
For convenience, you may use the `acceptJson` method to quickly specify that your application expects the `application/json` content type in response to your request:
136136

137137
$response = Http::acceptJson()->get('http://example.com/users');
@@ -385,9 +385,9 @@ Or, you may use the `assertNothingSent` method to assert that no requests were s
385385
<a name="events"></a>
386386
## Events
387387

388-
Laravel fires two events during the process of sending HTTP requests. The `RequestSending` event is fired prior to a request being sent, while the `ResponseReceived` event is fired after a response is received for a given request.
388+
Laravel fires three events during the process of sending HTTP requests. The `RequestSending` event is fired prior to a request being sent, while the `ResponseReceived` event is fired after a response is received for a given request. The `ConnectionFailed` event is fired if no response is received for a given request.
389389

390-
The `RequestSending` event contains a public `$request` property that you may use to inspect the `Illuminate\Http\Client\Request` instance. Likewise, the `ResponseReceived` event contains a `$request` property as well as a `$response` property which may be used to inspect the `Illuminate\Http\Client\Response` instance. You may register event listeners for this event in your `App\Providers\EventServiceProvider` service provider:
390+
The `RequestSending` and `ConnectionFailed` events both contain a public `$request` property that you may use to inspect the `Illuminate\Http\Client\Request` instance. Likewise, the `ResponseReceived` event contains a `$request` property as well as a `$response` property which may be used to inspect the `Illuminate\Http\Client\Response` instance. You may register event listeners for this event in your `App\Providers\EventServiceProvider` service provider:
391391

392392
/**
393393
* The event listener mappings for the application.
@@ -401,4 +401,7 @@ The `RequestSending` event contains a public `$request` property that you may us
401401
'Illuminate\Http\Client\Events\ResponseReceived' => [
402402
'App\Listeners\LogResponseReceived',
403403
],
404+
'Illuminate\Http\Client\Events\ConnectionFailed' => [
405+
'App\Listeners\LogConnectionFailed',
406+
],
404407
];

0 commit comments

Comments
 (0)