Deserialize a response string to a response instance.
public static fromString ( string $message ) : |
||
$message | string | |
Результат |
/** * @param string $fileName * @param RequestInterface $request * @param string $type * @return ResponseInterface */ private function executePhpFile($fileName, RequestInterface $request, $type) { $process = $this->getProcess($fileName, $request); $process->start(); $this->eventDispatcher->dispatch(new CgiExecuteEvent(sprintf('cgi.verify.%s.executing', $type), $request)); $process->wait(); if (!$process->isSuccessful()) { throw CodeExecutionException::fromProcess($process); } //if no status line, pre-pend 200 OK $output = $process->getOutput(); if (!preg_match('/^HTTP\\/([1-9]\\d*\\.\\d) ([1-5]\\d{2})(\\s+(.+))?\\r\\n/', $output)) { $output = "HTTP/1.0 200 OK\r\n" . $output; } return ResponseSerializer::fromString($output); }
public function unserialize($serialized) { $data = unserialize($serialized); $this->requestData = $data['requestData']; if (isset($data['request'])) { $this->request = \Zend\Diactoros\Request\Serializer::fromString($data['request']); } if (isset($data['response'])) { $this->response = \Zend\Diactoros\Response\Serializer::fromString($data['response']); } }
/** * Create discover event * * @param string $message * * @return DiscoverEvent */ protected function createDiscoverEvent($message) { $response = ResponseSerializer::fromString($message); $event = new DiscoverEvent(); if ($response->hasHeader('CACHE-CONTROL')) { $value = $response->getHeaderLine('CACHE-CONTROL'); $event->setLifetime(intval(substr($value, strpos($value, '=') + 1))); } if ($response->hasHeader('DATE')) { $event->setDate(new \DateTime($response->getHeaderLine('DATE'))); } if ($response->hasHeader('LOCATION')) { $event->setDescriptionUrl(new Uri($response->getHeaderLine('LOCATION'))); } if ($response->hasHeader('SERVER')) { $event->setServerString($response->getHeaderLine('SERVER')); } if ($response->hasHeader('ST')) { $event->setSearchTargetString($response->getHeaderLine('ST')); } if ($response->hasHeader('USN')) { $event->setUniqueServiceNameString($response->getHeaderLine('USN')); } return $event; }