FIX Skip md5-ing the whole contents of a stream for etags

This commit is contained in:
Guy Marriott 2019-07-30 08:25:03 +12:00
parent 40f06fafa9
commit 0abfed3e06
No known key found for this signature in database
GPG Key ID: A80F9ACCB86D3DA7

View File

@ -4,6 +4,7 @@ namespace SilverStripe\Control\Middleware;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Control\HTTPStreamResponse;
use SilverStripe\Core\Injector\Injectable;
/**
@ -69,6 +70,11 @@ class ChangeDetectionMiddleware implements HTTPMiddleware
return $etag;
}
// Skip parsing the whole body of a stream
if ($response instanceof HTTPStreamResponse) {
return false;
}
// Generate etag from body
return sprintf('"%s"', md5($response->getBody()));
}