/** * @dataProvider getErrorMapping * @param string $httpMethod * @param int $statusCode * @param string $description */ public function testErrorDescriptions($httpMethod, $statusCode, $description) { $request = RequestFactory::getInstance()->fromMessage("{$httpMethod} /container/ HTTP/1.1\r\n" . "Host: www.foo.bar\r\n"); $response = new Response($statusCode); $prevException = BadResponseException::factory($request, $response); $httpException = HttpException::factory($prevException); $this->assertEquals($description, $httpException->getDescription()); }
/** * Sends a single request to a WebDAV server * * @param HttpRequest $request * The request * * @throws Exception\NoSuchResourceException * @throws Exception\HttpException * @return HttpResponse Returns the server response */ protected function doRequest(HttpRequest $request) { $error = null; $response = null; $this->lastRequest = $request; $this->lastResponse = null; try { $response = $request->send(); } catch (BadResponseException $error) { $response = $error->getResponse(); } // Creates History $this->lastResponse = $response; if ($error && $this->throwExceptions) { switch ($response->getStatusCode()) { case 404: throw new NoSuchResourceException('No such file or directory'); default: throw HttpException::factory($error); } } return $response; }