Spaces:
Running
Running
Download app/Http/Middleware/GzipMiddleware.php from lisatthu35/ewa: direct link, hf CLI and curl.
- Browser
- Download file 676 Bytes
-
https://huggingface.co/spaces/lisatthu35/ewa/resolve/main/app/Http/Middleware/GzipMiddleware.php
- Command line
-
hf download hf://spaces/lisatthu35/ewa/app/Http/Middleware/GzipMiddleware.php
-
curl -L -o GzipMiddleware.php https://huggingface.co/spaces/lisatthu35/ewa/resolve/main/app/Http/Middleware/GzipMiddleware.php
676 Bytes
| namespace App\Http\Middleware; | |
| use Closure; | |
| class GzipMiddleware | |
| { | |
| /** | |
| * Handle an incoming request. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @param \Closure $next | |
| * @return mixed | |
| */ | |
| public function handle($request, Closure $next) | |
| { | |
| $response = $next($request); | |
| $content = $response->content(); | |
| $data = gzencode($content, 9); | |
| return response($data)->withHeaders([ | |
| 'Access-Control-Allow-Origin' => '*', | |
| 'Access-Control-Allow-Methods'=> 'GET', | |
| 'Content-Length'=> strlen($data), | |
| 'Content-Encoding' => 'gzip' | |
| ]); | |
| } | |
| } |