/** * {@inheritdoc} */ public function request($path, $body = null, $httpMethod = 'GET', array $headers = array(), array $options = array()) { $response = parent::request($path, $body, $httpMethod, $headers, $options); if (304 == $response->getStatusCode()) { return $this->getCache()->get($path); } $this->getCache()->set($path, $response); return $response; }
/** * {@inheritdoc} */ public function request($path, array $parameters = array(), $httpMethod = 'GET', array $headers = array()) { $response = parent::request($path, $parameters, $httpMethod, $headers); $key = trim($this->options['base_url'] . $path, '/'); if (304 == $response->getStatusCode()) { return $this->getCache()->get($key); } $this->getCache()->set($key, $response); return $response; }
/** * {@inheritdoc} */ public function request($path, $body = null, $httpMethod = 'GET', array $headers = array(), array $options = array()) { $response = parent::request($path, $body, $httpMethod, $headers, $options); if (304 == $response->getStatusCode()) { $cacheResponse = $this->getCache()->get($this->id); $this->lastCachedResponse = $cacheResponse; return $cacheResponse; } if (in_array($httpMethod, array('GET', 'HEAD'), true)) { $this->getCache()->set($this->id, $response); } return $response; }
/** * @test */ public function shouldHandlePagination() { $path = '/some/path'; $parameters = array('a' => 'b'); $headers = array('c' => 'd'); $response = new Response(); $response->addHeader("Link:<page1>; rel=\"page2\", \n<page3>; rel=\"page4\""); $client = $this->getBrowserMock(); $httpClient = new HttpClient(array(), $client); $httpClient->request($path, $parameters, 'HEAD', $headers); $this->assertEquals(array('page2' => 'page1', 'page4' => 'page3'), $response->getPagination()); }
/** * @test */ public function shouldHandlePagination() { $path = '/some/path'; $body = 'a = b'; $headers = array('c' => 'd'); $response = new Response(200); $response->addHeader('Link', "<page1>; rel=\"page2\", \n<page3>; rel=\"page4\""); $client = $this->getBrowserMock(); $httpClient = new HttpClient(array(), $client); $httpClient->request($path, $body, 'HEAD', $headers); $this->assertEquals(array('page2' => 'page1', 'page4' => 'page3'), ResponseMediator::getPagination($response)); }