n2n Page Rocket 1 API

n2n\web\http\payload

­Buffered­Payload

abstract BufferedPayload implements Payload
Extend this class for an easy implemenation of an bufferable Payload. See {@Payload::isBufferable() for more information.

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 ( )

  • Specified: Payload
    Overrides: 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);
    		  
    	

    see
    return
    string
    throws
    Specified: Payload
    Overrides: 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

    see
    return
    n2n\web\http\payload\string|null
    throws
    Specified: Payload
    Overrides: 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.

    see
    return
    DateTime|null
    throws
    Specified: Payload
    Overrides: Payload::getLastModified()