public function testHeadCollectionETagHeader()
 {
     $testPath = '/collection/';
     $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/');
     $etag = $backend->getProperty($testPath, 'getetag')->etag;
     $req = new ezcWebdavHeadRequest($testPath);
     $req->validateHeaders();
     $res = $backend->head($req);
     $expectedRes = new ezcWebdavHeadResponse(new ezcWebdavCollection($testPath, $backend->getAllProperties($testPath)));
     $expectedRes->setHeader('ETag', $etag);
     $this->assertEquals($expectedRes, $res, 'Expected response does not match real response.', 0, 20);
 }
 public function testCollectionHead()
 {
     if (version_compare(PHP_VERSION, '5.2.6', '<')) {
         $this->markTestSkipped('PHP DateTime broken in versions < 5.2.6');
         return;
     }
     $backend = new ezcWebdavMemoryBackend();
     $backend->addContents(array('foo' => 'bar', 'bar' => array('blubb' => 'Somme blubb blubbs.')));
     $request = new ezcWebdavHeadRequest('/bar');
     $request->validateHeaders();
     $response = $backend->head($request);
     $expectedResponse = new ezcWebdavHeadResponse(new ezcWebdavCollection('/bar', $backend->initializeProperties('/bar', true)));
     $expectedResponse->setHeader('ETag', '6a764eebfa109a9ef76c113f3f608c6b');
     $this->assertEquals($expectedResponse, $response, 'Expected response does not match real response.', 0, 20);
 }
Beispiel #3
0
 /**
  * Serves HEAD requests.
  *
  * The method receives a {@link ezcWebdavHeadRequest} object containing all
  * relevant information obout the clients request and will return an {@link
  * ezcWebdavErrorResponse} instance on error or an instance of {@link
  * ezcWebdavHeadResponse} on success.
  * 
  * @param ezcWebdavHeadRequest $request
  * @return ezcWebdavResponse
  */
 public function head(ezcWebdavHeadRequest $request)
 {
     $source = $request->requestUri;
     // Check authorization
     if (!ezcWebdavServer::getInstance()->isAuthorized($source, $request->getHeader('Authorization'))) {
         return $this->createUnauthorizedResponse($source, $request->getHeader('Authorization'));
     }
     // Check if resource is available
     if (!$this->nodeExists($source)) {
         return new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_404, $source);
     }
     $res = null;
     // Init
     if (!$this->isCollection($source)) {
         // Just deliver file without contents
         $res = new ezcWebdavHeadResponse(new ezcWebdavResource($source, $this->getAllProperties($source)));
     } else {
         // Just deliver collection without children
         $res = new ezcWebdavHeadResponse(new ezcWebdavCollection($source, $this->getAllProperties($source)));
     }
     // Add ETag header
     $res->setHeader('ETag', $this->getETag($source));
     // Deliver response
     return $res;
 }
Beispiel #4
0
 public function testCollectionHead()
 {
     $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/');
     $request = new ezcWebdavHeadRequest('/collection');
     $request->validateHeaders();
     $response = $backend->head($request);
     $expectedResponse = new ezcWebdavHeadResponse(new ezcWebdavCollection('/collection', $backend->getAllProperties('/collection')));
     $expectedResponse->setHeader('ETag', $backend->getProperty('/collection', 'getetag')->etag);
     $this->assertEquals($expectedResponse, $response, 'Expected response does not match real response.', 0, 20);
 }
Beispiel #5
0
 /**
  * Creates display information for a HEAD response of a collection resource.
  * 
  * Generates default Content-Type and Content-Length header, if not set in
  * the $response (generated from the backend). Content-Type is set to .
  * 
  * @param ezcWebdavHeadResponse $response 
  * @return ezcWebdavEmptyDisplayInformation
  */
 private function processHeadCollectionResponse(ezcWebdavHeadResponse $response)
 {
     // Generate default Content-Type header if necessary
     if ($response->getHeader('Content-Type') === null) {
         $response->setHeader('Content-Type', 'httpd/unix-directory');
     }
     // Generate default Content-Length header if necessary
     if ($response->getHeader('Content-Length') === null) {
         $response->setHeader('Content-Length', ezcWebdavGetContentLengthProperty::COLLECTION);
     }
     return new ezcWebdavEmptyDisplayInformation($response);
 }