AppserverIo\Appserver\ServletEngine\Http\Response::init PHP Метод

init() публичный Метод

Initialises the response object to default properties.
public init ( ) : void
Результат void
    public function init()
    {
        // init body stream
        $this->bodyStream = '';
        // init exception
        $this->exception = null;
        // init default response properties
        $this->statusCode = 200;
        $this->version = 'HTTP/1.1';
        $this->statusReasonPhrase = "OK";
        $this->mimeType = "text/plain";
        $this->state = HttpResponseStates::INITIAL;
        // initialize cookies and headers
        $this->cookies = array();
        $this->headers = array();
        // initialize the default headers
        $this->initDefaultHeaders();
    }

Usage Example

Пример #1
0
 /**
  * Tests the result process() method without any data in the result
  *
  * @return void
  */
 public function testProcessWithoutAnyData()
 {
     // create a mock servlet request instance
     $mockServletRequest = $this->getMock('AppserverIo\\Appserver\\ServletEngine\\Http\\Request');
     // create a mock servlet response instance
     $servletResponse = new Response();
     $servletResponse->init();
     // set the action instance
     $this->result->setAction($this);
     // process the result
     $this->result->process($mockServletRequest, $servletResponse);
     // test if the response body is truly empty
     $this->assertEmpty($servletResponse->getBodyContent());
 }
All Usage Examples Of AppserverIo\Appserver\ServletEngine\Http\Response::init