Example #1
0
 public function close($force = false)
 {
     UltraMilk_FCGI_Record::write($this->conn, new UltraMilk_FCGI_EndRequestRecord($this->version, $this->requestId, $this->status, UltraMilk_FCGI_EndRequestRecord::REQUEST_COMPLETE));
     if ($this->flags !== UltraMilk_FCGI_BeginRequestRecord::KEEP_CONN || $force == true) {
         fclose($this->conn);
     }
 }
 private function createChild($socket, $count)
 {
     while ($conn = stream_socket_accept($socket, -1)) {
         while ($record = UltraMilk_FCGI_Record::read($conn)) {
             if ($record->getType() == UltraMilk_FCGI_RecordTypes::BEGIN_REQUEST) {
                 if ($record->getRole() !== $this->role) {
                     throw new RuntimeException('UltraMilk role not equal request role!');
                 }
                 if ($record->getRole() == UltraMilk_FCGI_Roles::RESPONDER) {
                     $this->onRequestHandler->invoke(new UltraMilk_HTTP_Request(UltraMilk_FCGI_Request::create($conn, $record->getVersion(), $this->role, $record->getRequestId(), $record->getFlags())));
                 } else {
                     throw new RuntimeException('This role doesn\'t supported at this moment!');
                 }
             }
             unset($record);
             if (!is_resource($conn)) {
                 break;
             }
         }
     }
 }
 public function __construct($version, $requestId, $content)
 {
     parent::__construct($version, UltraMilk_FCGI_RecordTypes::STDIN, $requestId, $content);
 }
 public function close()
 {
     if ($this->closed) {
         return;
     }
     UltraMilk_FCGI_Record::write($this->conn, new UltraMilk_FCGI_Record($this->version, $this->type, $this->requestId, null));
 }
 public function __construct($version, $requestId)
 {
     parent::__construct($version, UltraMilk_FCGI_RecordTypes::ABORT_REQUEST, $requestId, null);
 }
 public function __construct($version, $requestId, $appStatus, $protocolStatus)
 {
     parent::__construct($version, UltraMilk_FCGI_RecordTypes::END_REQUEST, $requestId, null);
     $this->appStatus = $appStatus;
     $this->protocolStatus = $protocolStatus;
 }
 public function __construct($version, $requestId, $params)
 {
     parent::__construct($version, UltraMilk_FCGI_RecordTypes::PARAMS, $requestId, $params);
 }
 public function __construct($version, $requestId, $role, $flags)
 {
     parent::__construct($version, UltraMilk_FCGI_RecordTypes::BEGIN_REQUEST, $requestId, null);
     $this->role = $role;
     $this->flags = $flags;
 }