Example #1
0
 /**
  * {@inheritdoc}
  */
 public function validateResponse(Request $request, Response $response) : bool
 {
     if (Response::SWITCHING_PROTOCOLS !== $response->getStatusCode()) {
         return false;
     }
     if ('upgrade' !== strtolower($response->getHeader('Connection'))) {
         return false;
     }
     if ('websocket' !== strtolower($response->getHeader('Upgrade'))) {
         return false;
     }
     $key = $request->getHeader('Sec-WebSocket-Key');
     if (!$response->hasHeader('Sec-WebSocket-Accept')) {
         return false;
     }
     return $this->responseKey($key) === $response->getHeader('Sec-WebSocket-Accept');
 }
Example #2
0
 /**
  * Ensure a date is sent with the Response.
  *
  * @link https://tools.ietf.org/html/rfc2616#section-14.18
  * @return void
  */
 protected function ensureDate()
 {
     if (!$this->response->hasHeader("Date")) {
         $this->response->setDateHeader("Date", new \DateTime());
     }
 }
 public function testHasHeader()
 {
     $this->assertThat($this->object->hasHeader('udnefined-header'), $this->equalTo(false));
     $this->object->setHeader('Some header', 'val');
     $this->assertThat($this->object->hasHeader('some header'), $this->equalTo(true));
 }