Md5ValidatorPlugin
in package
implements
EventSubscriberInterface
Ensures that an the MD5 hash of an entity body matches the Content-MD5 header (if set) of an HTTP response. An exception is thrown if the calculated MD5 does not match the expected MD5.
Interfaces, Classes and Traits
- EventSubscriberInterface
- An EventSubscriber knows itself what events it is interested in.
Table of Contents
- $contentEncoded : bool
- $contentLengthCutoff : int
- __construct() : mixed
- getSubscribedEvents() : array<string|int, mixed>
- Returns an array of event names this subscriber wants to listen to.
- onRequestComplete() : mixed
- {@inheritdoc}
Properties
$contentEncoded
protected
bool
$contentEncoded
Whether or not to compare when a Content-Encoding is present
$contentLengthCutoff
protected
int
$contentLengthCutoff
Maximum Content-Length in bytes to validate
Methods
__construct()
public
__construct([bool $contentEncoded = true ][, bool|int $contentLengthCutoff = false ]) : mixed
Parameters
- $contentEncoded : bool = true
-
Calculating the MD5 hash of an entity body where a Content-Encoding was applied is a more expensive comparison because the entity body will need to be compressed in order to get the correct hash. Set to FALSE to not validate the MD5 hash of an entity body with an applied Content-Encoding.
- $contentLengthCutoff : bool|int = false
-
Maximum Content-Length (bytes) in which a MD5 hash will be validated. Any response with a Content-Length greater than this value will not be validated because it will be deemed too memory intensive.
Return values
mixed —getSubscribedEvents()
Returns an array of event names this subscriber wants to listen to.
public
static getSubscribedEvents() : array<string|int, mixed>
The array keys are event names and the value can be:
- The method name to call (priority defaults to 0)
- An array composed of the method name to call and the priority
- An array of arrays composed of the method names to call and respective priorities, or 0 if unset
For instance:
- ['eventName' => 'methodName']
- ['eventName' => ['methodName', $priority]]
- ['eventName' => [['methodName1', $priority], ['methodName2']]]
The code must not depend on runtime state as it will only be called at compile time. All logic depending on runtime state must be put into the individual methods handling the events.
Return values
array<string|int, mixed> —The event names to listen to
onRequestComplete()
{@inheritdoc}
public
onRequestComplete(Event $event) : mixed
Parameters
- $event : Event