Skip to content

Commit

Permalink
The middleware terminate method descripton is misleading.
Browse files Browse the repository at this point in the history
From the current version you can think that something will be done on server side, when the browser will really receive the response. THIS IS NOT TRUE - if you will put e.g. sleep(10) in the terminate method - you will see in the browser that you will have to wait those additional 10second for the response from server to be done.

I've checked this using php artisan serve and also by running it on Apache 2.4 with php 7.2 installed.
  • Loading branch information
DevparkAnders committed Mar 15, 2018
1 parent fe11fd8 commit 984d785
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ Middleware parameters may be specified when defining the route by separating the
<a name="terminable-middleware"></a>
## Terminable Middleware

Sometimes a middleware may need to do some work after the HTTP response has been sent to the browser. For example, the "session" middleware included with Laravel writes the session data to storage after the response has been sent to the browser. If you define a `terminate` method on your middleware, it will automatically be called after the response is sent to the browser.
Sometimes a middleware may need to do some work after the HTTP response has been prepared to be send. For example, the "session" middleware included with Laravel writes the session data to storage after the response has been prepared to be sent to the browser. If you define a `terminate` method on your middleware, it will automatically be called after the response is prepared to be sent to the browser.

<?php

Expand Down

1 comment on commit 984d785

@mvestil
Copy link
Contributor

@mvestil mvestil commented on 984d785 Jul 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the previous version is true when i tested.

Using nginx 1.16.0 and php 7.1.29 in a Vagrant environment, not php artisan serve.

I put a 5 seconds sleep inside the terminate and added a log.
Made a request to the server via AJAX, got a JSON response from the server, after 5 seconds, my log was logged in the laravel log file.

Please sign in to comment.