bilfeldt / laravel-route-statistics

Log requests and group together for aggregated statistics of route usage
MIT License
227 stars 23 forks source link

Streamed responses fail with call to undefined method #3

Closed bilfeldt closed 3 years ago

bilfeldt commented 3 years ago

Description

When returning a streamed response (download of file) then the following error is thrown:

Call to undefined method Symfony\Component\HttpFoundation\StreamedResponse::status()

which is caused by

$event->response->status() // src/Listeners/LogRouteStatistics.php:26

Flare error: https://flareapp.io/share/x5MqjZe5

Steps to recreate

  1. Add a csv file to a disk
  2. Add the route below
  3. Visit the route /test in a browser
// web.php

Route::get('/test', function () {
    return Storage::download('test.csv');
});
bilfeldt commented 3 years ago

Solved in #4 by using getStatusCode() instead of status()