Webdav: ezcWebdavServer
[ ]
[ Clients ] [ Plugin architecture ]
[ ]
[ ]
[ ]
[ ]
Class: ezcWebdavServer
|
Base class for creating a webdav server, capable of serving webdav requests. [
source]
1. $server = ezcWebdavServer::getInstance();
2.
3. // Optionally register aditional transport handlers
4.
5. // This step is only required, if you want to add custom or third party extensions
6. // implementations for special clients.
7. $server->configurations[] = new ezcWebdavServerConfiguration(
8. // Regular expression to match client name
9. '(My.*Webdav\s+Cliengt)i',
10. // Class name of transport handler, extending <a href="../Webdav/ezcWebdavTransport.html">ezcWebdavTransport</a>
11. 'myCustomTransportTransport'
12. );
13. $server->configurations[] = new ezcWebdavServerConfiguration(
14. // Regular expression to match client name
15. '(.*Firefox.*)i',
16. // Class name of transport handler, extending <a href="../Webdav/ezcWebdavTransport.html">ezcWebdavTransport</a>
17. 'customWebdavMozillaTransport',
18. // A custom implementation of <a href="../Webdav/ezcWebdavXmlTool.html">ezcWebdavXmlTool</a>
19. 'customWebdavXmlTool',
20. // A custom implementation of <a href="../Webdav/ezcWebdavPropertyHandler.html">ezcWebdavPropertyHandler</a>
21. 'customWebdavPropertyHandler',
22. // A custom path factory
23. new customWebdavPathFactory()
24. );
25.
26. // Serve data using file backend with data in "path/"
27. $backend = new ezcWebdavBackendFile( '/path' );
28.
29. // Make the server serve WebDAV requests
30. $server->handle( $backend );
Properties
Member Variables
Method Summary
|
protected void |
__construct(
)
Creates a new instance. |
|
public ezcWebdavErrorResponse |
createUnauthorizedResponse(
$uri, $desc, $desc
)
Creates an ezcWebdavErrorResponse to indicate unauthorized access. |
|
public static ezcWebdavServer |
getInstance(
)
Returns singleton instance. |
|
public void |
handle(
$backend, [$uri = null], $uri
)
Handles the current request. |
|
public void |
init(
$pathFactory, $xmlTool, $propertyHandler, $headerHandler, $transport )
Initializes the server with the given objects. |
|
public bool |
isAuthorized(
$request, $path, [$access = ezcWebdavAuthorizer::ACCESS_READ] )
Performs authorization. |
|
public void |
reset(
)
Reset the server to its initial state. |
Methods
__construct
void __construct(
)
Creates a new instance.
The constructor is protected due to singleton reasons. Use
getInstance() and then use the properties of the server to adjust its configuration.
createUnauthorizedResponse
Creates an ezcWebdavErrorResponse to indicate unauthorized access.
Parameters
| Name |
Type |
Description |
$uri |
string |
|
$desc
|
string |
|
$desc |
|
|
getInstance
Returns singleton instance.
The instantiation of 2 WebDAV servers at the same time does not make sense and could possibly cause strange effects, like double sending of a response. Therefore the server implements a singleton and its only instance must be retrieved using this method. Configuration changes can then be performed through the properties of this instance.
handle
Handles the current request.
This method is the absolute heart of the Webdav component. It is called to make the server instance handle the current request. This means, a
ezcWebdavTransport is selected and instantiated through the
ezcWebdavServerConfigurationManager in $configurations. This transport (and all other objects, created from the configuration) is used to parse the incoming request into an instance of
ezcWebdavRequest, which is then handed to the submitted $backend for handling. The resulting
ezcWebdavResponse is serialized by the
ezcWebdavTransport and send back to the client.
The method receives at least an instance of
ezcWebdavBackend, which is used to server the request. Optionally, the request URI can be submitted in $uri. If this is not the case, the request URI is determined by the server variables
- $_SERVER['SERVER_NAME']
- $_SERVER['REQUEST_URI']
Parameters
init
Initializes the server with the given objects.
This method is marked proteced, because it is intended to be used by by
ezcWebdavServerConfiguration instances and instances of derived classes, but not directly.
Parameters
isAuthorized
bool isAuthorized(
ezcWebdavRequest
$request, string
$path, [int
$access = ezcWebdavAuthorizer::ACCESS_READ] )
Performs authorization.
This method does several things:
- Check if authorization is enabled by ezcWebdavServer->$auth
- If it is, extract username from Authenticate header or choose ''
- Check authorization
It returns true, if authorization is not enabled or succeeded. False is returned otherwise.
Parameters
reset
void reset(
)
Reset the server to its initial state.
Resets the internal server state as if a new instance has just been constructed.
Last updated: Mon, 13 Oct 2008