n2n Page Rocket 1 API

n2n\web\http\payload

­Payload

Payload

Implemented by:

Methods summary

Modifier and Type Method
public prepareForResponse ( Response response )
public string toKownPayloadString ( )
public bool isBufferable ( )
public string getBufferedContents ( )
public string responseOut ( )
public string|null getEtag ( )
public DateTime|null getLastModified ( )

Methods in detail

    • 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:

      		
      	

      return
      bool
  • getBufferedContents

    string public getBufferedContents ( )
    Returns the buffered content of this response object. See Payload::isBufferable() for more information.
    return
    string
    throws
    IllegalStateException if Payload returns false.
  • 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);
    		  
    	

    return
    string
    throws
  • 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

    return
    n2n\web\http\payload\string|null
    throws
  • 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.

    return
    DateTime|null
    throws