/** * Reads a page of results, usually of type \Gedcomx\Atom\Feed. * * @param string $rel The rel * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,... zero or more StateTransitionOption objects * * @return \Gedcomx\Rs\Client\GedcomxApplicationState The requested page. */ protected function readPage($rel, StateTransitionOption $option = null) { $link = $this->getLink($rel); if ($link === null || $link->getHref() === null) { return null; } $headers = ['Accept' => count($this->request->getHeader("Accept")) > 0 ? $this->request->getHeader("Accept")[0] : null, 'Content-Type' => count($this->request->getHeader("Content-Type")) > 0 ? $this->request->getHeader("Content-Type")[0] : null]; $request = $this->createAuthenticatedRequest($this->request->getMethod(), $link->getHref(), $headers); $class = get_class($this); return new $class($this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken, $this->stateFactory); }
public function verifySubProtocol(Request $request, Response $response) { $subProtocolRequest = $request->getHeader('Sec-WebSocket-Protocol'); if (empty($subProtocolRequest)) { return true; } $subProtocolResponse = $response->getHeader('Sec-WebSocket-Protocol'); if (count($subProtocolResponse) !== 1) { // there should be exactly one subprotocol sent back if we requested return false; } if (in_array($subProtocolResponse[0], $subProtocolRequest)) { // the response is one of the requested subprotocols return true; } return false; }
/** * @param $header * @return array */ public function getHeader($header) { $psrHeader = $this->request->getHeader($header); return null === $psrHeader ? null : strtolower(reset($psrHeader)); }
/** * Ensure a single header value is set correctly. * * @param Request $request * @param string $header * @param string $value */ protected function assertHeaderValue(Request $request, $header, $value) { $headerValue = $request->getHeader($header); $this->assertCount(1, $headerValue); $this->assertEquals($value, $headerValue[0]); }