/** * Required method to serve OPTIONS requests. * * The method receives a {@link ezcWebdavOptionsRequest} object containing all * relevant information obout the clients request and should either return * an error by returning an {@link ezcWebdavErrorResponse} object, or any * other {@link ezcWebdavResponse} objects. * * @param ezcWebdavOptionsRequest $request * @return ezcWebdavResponse */ public function options(ezcWebdavOptionsRequest $request) { $response = new ezcWebdavOptionsResponse('1'); // Always allowed $allowed = 'GET, HEAD, PROPFIND, PROPPATCH, OPTIONS, '; // Check if modifications are allowed if ($this instanceof ezcWebdavBackendChange) { $allowed .= 'DELETE, COPY, MOVE, '; } // Check if MKCOL is allowed if ($this instanceof ezcWebdavBackendMakeCollection) { $allowed .= 'MKCOL, '; } // Check if PUT is allowed if ($this instanceof ezcWebdavBackendPut) { $allowed .= 'PUT, '; } // Check if LOCK and UNLOCK are allowed if ($this instanceof ezcWebdavLockBackend) { $allowed .= 'LOCK, UNLOCK, '; } $response->setHeader('Allow', substr($allowed, 0, -2)); return $response; }
public function testValidateHeadersFailure() { $response = new ezcWebdavOptionsResponse(); $response->setHeader('DAV', null); try { $response->validateHeaders(); $this->fail("Exception not thrown on missing header 'DAV'."); } catch (ezcWebdavMissingHeaderException $e) { } $response->setHeader('DAV', '1, 2#extended'); try { $response->validateHeaders(); $this->fail("Exception not thrown on invalid header 'DAV'."); } catch (ezcWebdavInvalidHeaderException $e) { } }