| Conditions | 4 |
| Paths | 8 |
| Total Lines | 28 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 20 | public function handle(Request $request, Closure $next) |
||
| 21 | { |
||
| 22 | // Handle request |
||
| 23 | $method = $request->getMethod(); |
||
| 24 | |||
| 25 | // Support using HEAD method for checking If-None-Match |
||
| 26 | if ($request->isMethod('HEAD')) { |
||
| 27 | $request->setMethod('GET'); |
||
| 28 | } |
||
| 29 | |||
| 30 | //Handle response |
||
| 31 | $response = $next($request); |
||
| 32 | |||
| 33 | $etag = EtagConditionals::getEtag($request, $response); |
||
| 34 | $noneMatch = $request->getETags(); |
||
| 35 | |||
| 36 | // Strip W/ if weak comparison algorithm can be used |
||
| 37 | if (config('etagconditionals.if_none_match_weak')) { |
||
| 38 | $noneMatch = array_map([$this, 'stripWeakTags'], $noneMatch); |
||
| 39 | } |
||
| 40 | |||
| 41 | if (in_array($etag, $noneMatch)) { |
||
| 42 | $response->setNotModified(); |
||
| 43 | } |
||
| 44 | |||
| 45 | $request->setMethod($method); |
||
| 46 | |||
| 47 | return $response; |
||
| 48 | } |
||
| 55 |