/** * HTTP HEAD * * This method is normally used to take a peak at a url, and only get the * HTTP response headers, without the body. This is used by clients to * determine if a remote file was changed, so they can use a local cached * version, instead of downloading it again * * @param RequestInterface $request * @param ResponseInterface $response * @return bool */ function httpHead(RequestInterface $request, ResponseInterface $response) { // This is implemented by changing the HEAD request to a GET request, // and dropping the response body. $subRequest = clone $request; $subRequest->setMethod('GET'); try { $this->server->invokeMethod($subRequest, $response, false); $response->setBody(''); } catch (Exception\NotImplemented $e) { // Some clients may do HEAD requests on collections, however, GET // requests and HEAD requests _may_ not be defined on a collection, // which would trigger a 501. // This breaks some clients though, so we're transforming these // 501s into 200s. $response->setStatus(200); $response->setBody(''); $response->setHeader('Content-Type', 'text/plain'); $response->setHeader('X-Sabre-Real-Status', $e->getHTTPCode()); } // Sending back false will interupt the event chain and tell the server // we've handled this method. return false; }
/** * This test makes sure that a path like /foo cannot be copied into a path * like /foo/bar/ * * @expectedException \Sabre\DAV\Exception\Conflict */ public function testCopyIntoSubPath() { $dir = new FS\Directory(SABRE_TEMPDIR); $server = new Server($dir); $dir->createDirectory('foo'); $request = new HTTP\Request('COPY', '/foo', ['Destination' => '/foo/bar']); $response = new HTTP\ResponseMock(); $server->invokeMethod($request, $response); }