summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormxr5762018-04-21 14:54:01 (GMT)
committerLuca Lusso2018-04-21 14:54:01 (GMT)
commit8c52d2348bedeff63d734df064d36a27d467e17d (patch)
treee10d6f1e7eb3800ffd44ce4f7c2b2af9188addab
parent97807ce8f3e3d1e6cb2b65b2c25ee98872834ac8 (diff)
Issue #2948701 by mxr576: Do not override on_stats callback
-rw-r--r--webprofiler/src/Http/HttpClientMiddleware.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/webprofiler/src/Http/HttpClientMiddleware.php b/webprofiler/src/Http/HttpClientMiddleware.php
index b64a2a6..c37c0ca 100644
--- a/webprofiler/src/Http/HttpClientMiddleware.php
+++ b/webprofiler/src/Http/HttpClientMiddleware.php
@@ -36,8 +36,18 @@ class HttpClientMiddleware {
return function ($handler) {
return function (RequestInterface $request, array $options) use ($handler) {
- $options['on_stats'] = function (TransferStats $stats) use ($request) {
+ // If on_stats callback is already set then save it
+ // and call it after ours.
+ if (isset($options['on_stats'])) {
+ $next = $options['on_stats'];
+ }
+ else {
+ $next = function(TransferStats $stats) {};
+ }
+
+ $options['on_stats'] = function (TransferStats $stats) use ($request, $next) {
$request->stats = $stats;
+ $next($stats);
};
return $handler($request, $options)->then(