BufferedPayload
abstract BufferedPayload implements Payload
All Implemented Interfaces:
SubTypes
Methods summary
Modifier and Type | Method |
---|---|
public bool | isBufferable ( ) |
public string | responseOut ( ) |
public string|null | getEtag ( ) |
public DateTime|null | getLastModified ( ) |
Methods in detail
-
isBufferable
bool public isBufferable ( )Returns true if the content of this Payload can be buffered and returned by Payload::getBufferedContents(). This would be false if this Payload contained a large file which can not be buffered due to lack of memory.
Implemation examples:
Specified: PayloadOverrides: Payload::isBufferable() -
responseOut
string public responseOut ( )Flushes the response object directly to the client. See Payload::isBufferable() for more information.
Implementation example:
public function out() {@ IoUtils::readfile($this->fileFsPath);
Specified: PayloadOverrides: Payload::responseOut() -
getEtag
string|null public getEtag ( )Etag is sort of a hash of the content of this response object. It will be used to determine if the the response object has changed since the last request. If not n2n will send the http status 304 Not Modified which reduces traffice.
Notice: If Payload::isBufferable() is true, n2n is able to calcualte an etag on its own and this method will not be called!
Attention: Please make sure to return a proper etag according to the http standard
Specified: PayloadOverrides: Payload::getEtag() -
getLastModified
DateTime|null public getLastModified ( )Can be used as alternative to calculating an etag. Similar to etag the returned DateTime will be used to determine if the response object has changed since the last request. If not a http status 304 Not Modified will me sent which reduces traffice.
Also see Payload::getEtag()
Notice: If Payload::isBufferable() is true, n2n already uses an etag to determine if the if the response object has changed. So this method will not be called.
Specified: PayloadOverrides: Payload::getLastModified()