Webdav: ezcWebdavTransport
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcWebdavTransport
|
Transport layer mainclas that handles RFC compliant client communication. [
source]
This basis transport class is able to interact with RFC 2518 compliant WebDAV clients. It can parse all request types defined in the RFC into the abstraction layer of the Webdav component, defined by the base classes mentioned below.
To adjust this base transport layer main class to the needs of RFC-2518-inconform client implementations, there is the powerfull possibility of extending this class and overwriting certain necessary protected methods. The easier way to adjust smaller issues is to replace one of the helper components during construction of via property access.
The ezcWebdavServer->xmlTool property will be used which is accessed for different XML related operations. Exchanging this one will allow you to manipulate the XML handling for the transport layer in general.
The ezcWebdavServer->propertyHandler property, of type
ezcWebdavPropertyHandler will be used in the accordingly named property and is responsible for extracting WebDAV properties from a DOMElement and to serialize them back to one.
The ezcWebdavServer->pathFactory property must be an instance of
ezcWebdavPathFactory and is used to convert between internal WebDAV pathes (resource locations understood by the
ezcWebdavBackend) and URIs that reference a resource on the web.
An instance of this class is by default capable of parsing the follwoing HTTP request methods:
- COPY
- DELETE
- GET
- HEAD
- MKCOL
- MOVE
- OPTIONS
- PROPFIND
- PROPPATCH'
- PUT
The transport implementation is capable of handling the following response classes and output the to the client:
Descendents
Constants
VERSION
= '1.0alpha1'
|
Used for server software string in Server header. |
Member Variables
|
public mixed |
$handlingMap
= array( 'ezcWebdavCopyResponse' => 'processCopyResponse', 'ezcWebdavDeleteResponse' => 'processDeleteResponse', 'ezcWebdavErrorResponse' => 'processErrorResponse', 'ezcWebdavGetCollectionResponse' => 'processGetCollectionResponse', 'ezcWebdavGetResourceResponse' => 'processGetResourceResponse', 'ezcWebdavHeadResponse' => 'processHeadResponse', 'ezcWebdavMakeCollectionResponse' => 'processMakeCollectionResponse', 'ezcWebdavMoveResponse' => 'processMoveResponse', 'ezcWebdavMultistatusResponse' => 'processMultiStatusResponse', 'ezcWebdavOptionsResponse' => 'processOptionsResponse', 'ezcWebdavPropFindResponse' => 'processPropFindResponse', 'ezcWebdavPropPatchResponse' => 'processPropPatchResponse', 'ezcWebdavPutResponse' => 'processPutResponse', )
Map of response objects to handling methods. |
|
public array(string=>string) |
$parsingMap
= array( 'COPY' => 'parseCopyRequest', 'DELETE' => 'parseDeleteRequest', 'GET' => 'parseGetRequest', 'HEAD' => 'parseHeadRequest', 'MKCOL' => 'parseMakeCollectionRequest', 'MOVE' => 'parseMoveRequest', 'OPTIONS' => 'parseOptionsRequest', 'PROPFIND' => 'parsePropFindRequest', 'PROPPATCH' => 'parsePropPatchRequest', 'PUT' => 'parsePutRequest', )
Map of HTTP methods to object method names for parsing. |
|
protected array(string=>mixed) |
$properties
= array()
Properties. |
Method Summary
|
protected ezcWebdavOutputResult |
flattenResponse(
$info )
Flattens a processed response object to headers and body. |
|
protected ezcWebdavErrorResponse |
handleException(
$e, [$uri = null] )
Handle a thrown exception and generate an error response from it. |
|
public void |
handleResponse(
$response )
Handle a response and send it to the WebDAV client. |
|
protected ezcWebdavCopyRequest |
parseCopyRequest(
$path, $body )
Parses the COPY request and returns a request object. |
|
protected ezcWebdavDeleteRequest |
parseDeleteRequest(
$path, $body )
Parses the DELETE request and returns a request object. |
|
protected ezcWebdavGetRequest |
parseGetRequest(
$path, $body )
Parses the GET request and returns a request object. |
|
protected ezcWebdavHeadRequest |
parseHeadRequest(
$path, $body )
Parses the HEAD request and returns a request object. |
|
protected ezcWebdavMakeCollectionRequest |
parseMakeCollectionRequest(
$path, $body )
Parses the MKCOL request and returns a request object. |
|
protected ezcWebdavMoveRequest |
parseMoveRequest(
$path, $body )
Parses the MOVE request and returns a request object. |
|
protected ezcWebdavOptionsRequest |
parseOptionsRequest(
$path, $body )
Parses the OPTIONS request and returns a request object. |
|
protected ezcWebdavCopyRequest|ezcWebdavMoveRequest |
parsePropertyBehaviourContent(
$dom, $request )
Parses the <propertybehavior /> XML element. |
|
protected ezcWebdavPropFindRequest |
parsePropFindRequest(
$path, $body )
Parses the PROPFIND request and returns a request object. |
|
protected ezcWebdavPropPatchRequest |
parsePropPatchRequest(
$path, $body )
Parses the PROPPATCH request and returns a request object. |
|
protected ezcWebdavPutRequest |
parsePutRequest(
$path, $body )
Parses the PUT request and returns a request object. |
|
public ezcWebdavRequest|ezcWebdavResponse |
parseRequest(
$uri )
Parses the incoming request into a fitting request abstraction object. |
|
protected ezcWebdavEmptyDisplayInformation |
processCopyResponse(
$response )
Returns display information for a copy response object. |
|
protected ezcWebdavEmptyDisplayInformation |
processDeleteResponse(
$response )
Returns display information for a delete response object. |
|
protected ezcWebdavXmlDisplayInformation|ezcWebdavEmptyDisplayInformation |
processErrorResponse(
$response, [$xml = false] )
Returns display information for a error response object. |
|
protected ezcWebdavEmptyDisplayInformation |
processGetCollectionResponse(
$response )
Returns display information for a get response object for a collection. |
|
protected ezcWebdavStringDisplayInformation |
processGetResourceResponse(
$response )
Returns display information for a get response object for a non-collection resource. |
|
protected ezcWebdavEmptyDisplayInformation |
processHeadResponse(
$response )
Returns display information for a head response object. |
|
protected ezcWebdavEmptyDisplayInformation |
processMakeCollectionResponse(
$response )
Returns display information for a make collection response object. |
|
protected ezcWebdavEmptyDisplayInformation |
processMoveResponse(
$response )
Returns display information for a move response object. |
|
protected ezcWebdavXmlDisplayInformation |
processMultiStatusResponse(
$response )
Returns display information for a multistatus response object. |
|
protected ezcWebdavEmptyDisplayInformation |
processOptionsResponse(
$response )
Returns display information for a options response object. |
|
protected ezcWebdavXmlDisplayInformation |
processPropFindResponse(
$response )
Returns display information for a prop find response object. |
|
protected ezcWebdavEmptyDisplayInformation |
processPropPatchResponse(
$response )
Returns display information for a prop patch response object. |
|
protected ezcWebdavXmlDisplayInformation |
processPropStatResponse(
$response )
Returns display information for a prop stat response object. |
|
protected ezcWebdavEmptyDisplayInformation |
processPutResponse(
$response )
Returns display information for a put response object. |
|
protected string |
retreiveBody(
)
Returns the body content of the request. |
|
protected void |
sendResponse(
$output )
Finally send out the response. |
Methods
flattenResponse
Flattens a processed response object to headers and body.
Parameters
Redefined in descendants as
handleException
Handle a thrown exception and generate an error response from it.
For special exceptions, special responses will be generated:
- ezcWebdavBadRequestException: 400 Bad Request
- ezcWebdavInvalidRequestMethodException: 501 Not Implemented
Per default, a 500 Internal Server Error response will be generated.
Depending on where this is called, the generatedResponse hook will be issued (if during request parsing), but the processErrorResponse hooks will allways be called.
Parameters
| Name |
Type |
Description |
$e |
Exception |
|
$uri |
string |
|
handleResponse
Handle a response and send it to the WebDAV client.
This method is part of the integral communication API between the WebDAV client and the
ezcWebdavServer. It is declared final to ensure a minimal compatibile API between the extended classes and it is responsible to dispatch the
ezcWebdavPluginRegistry hooks.
It currently just maps internally to processResponse() and passes the result to {@ $this->sendResponse()}. It is not recommended that the $this->processResponse() method is overwritten, because this one takes care about the dispatching. The $this->sendResponse() may be overwritten, mainly for debugging, testing and logging purposes.
Parameters
parseCopyRequest
Parses the COPY request and returns a request object.
This method is responsible for parsing the COPY request. It retrieves the current request URI in $path and the request body as $body. The return value, if no exception is thrown, is a valid
ezcWebdavCopyRequest object.
This method may be overwritten to adjust it to special client behaviour.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$body |
string |
|
Throws
| Class | Description |
ezcWebdavInvalidRequestBodyException |
if the body of the copy request is invalid (XML wise or RFC wise). |
parseDeleteRequest
Parses the DELETE request and returns a request object.
This method is responsible for parsing the DELETE request. It retrieves the current request URI in $path and the request body as $body. The return value, if no exception is thrown, is a valid
ezcWebdavDeleteRequest object.
This method may be overwritten to adjust it to special client behaviour.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$body |
string |
|
parseGetRequest
Parses the GET request and returns a request object.
This method is responsible for parsing the GET request. It retrieves the current request URI in $path and the request body as $body. The return value, if no exception is thrown, is a valid ezcWebdavGet object.
This method may be overwritten to adjust it to special client behaviour.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$body |
string |
|
parseHeadRequest
Parses the HEAD request and returns a request object.
This method is responsible for parsing the HEAD request. It retrieves the current request URI in $path and the request body as $body. The return value, if no exception is thrown, is a valid ezcWebdavHead object.
This method may be overwritten to adjust it to special client behaviour.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$body |
string |
|
parseMakeCollectionRequest
Parses the MKCOL request and returns a request object.
This method is responsible for parsing the MKCOL request. It retrieves the current request URI in $path and the request body as $body. The return value, if no exception is thrown, is a valid
ezcWebdavMakeCollectionRequest object.
This method may be overwritten to adjust it to special client behaviour.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$body |
string |
|
parseMoveRequest
Parses the MOVE request and returns a request object.
This method is responsible for parsing the MOVE request. It retrieves the current request URI in $path and the request body as $body. The return value, if no exception is thrown, is a valid
ezcWebdavMoveRequest object.
This method may be overwritten to adjust it to special client behaviour.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$body |
string |
|
parseOptionsRequest
Parses the OPTIONS request and returns a request object.
This method is responsible for parsing the OPTIONS request. It retrieves the current request URI in $path and the request body as $body. The return value, if no exception is thrown, is a valid
ezcWebdavOptionsRequest object.
This method may be overwritten to adjust it to special client behaviour.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$body |
string |
|
parsePropertyBehaviourContent
Parses the <propertybehavior /> XML element.
This element is part of the COPY and MOVE requests, which are handled by $this->parseCopyRequest() respectivly $this->parseMoveRequest().
The $dom parameter is the DOMDocument where the <propertybehavior /> content should be parsed from. The $request object submitted will get the resulting
ezcWebdavRequestPropertyBehaviourContent set into its $propertyBehavior property.
This method may be overwritten to adjust it to special client behaviour. If you overwrite the $this->processCopyResponse() or $this->parseMoveRequest() methods, you might disable this method accedentally. You should explicitly use it there and overwrite it, if necessary. This makes extending your extension easier.
Parameters
parsePropFindRequest
Parses the PROPFIND request and returns a request object.
This method is responsible for parsing the PROPFIND request. It retrieves the current request URI in $path and the request body as $body. The return value, if no exception is thrown, is a valid
ezcWebdavPropFindRequest object.
This method may be overwritten to adjust it to special client behaviour.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$body |
string |
|
Redefined in descendants as
parsePropPatchRequest
Parses the PROPPATCH request and returns a request object.
This method is responsible for parsing the PROPPATCH request. It retrieves the current request URI in $path and the request body as $body. The return value, if no exception is thrown, is a valid
ezcWebdavPropPatchRequest object.
This method may be overwritten to adjust it to special client behaviour.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$body |
string |
|
parsePutRequest
Parses the PUT request and returns a request object.
This method is responsible for parsing the PUT request. It retrieves the current request URI in $path and the request body as $body. The return value, if no exception is thrown, is a valid ezcWebdavPut object.
This method may be overwritten to adjust it to special client behaviour.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$body |
string |
|
parseRequest
Parses the incoming request into a fitting request abstraction object.
The retrieval of the request body is performed by the
retreiveBody() method, the request method from $_SERVER['REQUEST_METHOD']. The latter one is mapped through the {self::$parsingMap} attribute to a local object method.
This method is marked final and may not be overwritten, because it belongs to the essential communication API with
ezcWebdavServer and is responsible to dispatch the
ezcWebdavPluginRegistry hooks of the transport layer.
Parameters
| Name |
Type |
Description |
$uri |
|
|
processCopyResponse
Returns display information for a copy response object.
The display information returned by this method indicates, that only headers, but no response body, should be send.
Parameters
processDeleteResponse
Returns display information for a delete response object.
The display information returned by this method indicates, that only headers, but no response body, should be send.
Parameters
processErrorResponse
Returns display information for a error response object.
The $xml parameter defines, if an XML representation should be generated, too (for use in $this->processMultiStatusResponse()), or if only the headers should be manipulated and an empty response body should be used.
The display information generated by this response contains the post processed $response and a DOMDocument representing the XML response body. If the $xml parameter is set to false, an empty display information is generated, to indicate that only headers should be send.
This method utilizes ezcWebdavServer::getInstance()->xmlTool to perform basic XML operations, so this is the place to perform such changeds. You should overwrite this method, if your client has problems specifically with the
ezcWebdavErrorResponse response.
Parameters
| Name |
Type |
Description |
$response |
ezcWebdavErrorResponse |
|
$xml |
bool |
DOMDocument in result only generated of true. |
processGetCollectionResponse
Returns display information for a get response object for a collection.
The display information returned by this method indicates, that only headers, but no response body, should be send.
Parameters
processGetResourceResponse
Returns display information for a get response object for a non-collection resource.
This method returns the display information generated for a $response object of type ezcWebdavGetResoucreResponse. It returns an instance of
ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.
This response returns a very seldom (for this component) string response, since it returns the raw content of the requested resource.
Parameters
processHeadResponse
Returns display information for a head response object.
The display information returned by this method indicates, that only headers, but no response body, should be send.
This method always must be structured quite similar to $this->processGetCollectionResponse or $this->processGetResourceResponse(), since HEAD is more or less GET without a body.
Parameters
processMakeCollectionResponse
Returns display information for a make collection response object.
The display information returned by this method indicates, that only headers, but no response body, should be send.
Parameters
processMoveResponse
Returns display information for a move response object.
The display information returned by this method indicates, that only headers, but no response body, should be send.
Parameters
processMultiStatusResponse
Returns display information for a multistatus response object.
This method returns the display information generated for a $response object of type ezcWebdavMultiStatusResponse. It returns an instance of
ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.
The display information generated by this response contains the post processed $response and a DOMDocument representing the XML response body.
This method utilizes ezcWebdavServer::getInstance()->xmlTool to perform basic XML operations, so this is the place to perform such changeds. You should overwrite this method, if your client has problems specifically with the ezcWebdavMultiStatusResponse response.
Parameters
| Name |
Type |
Description |
$response |
ezcWebdavMultiStatusResponse |
|
processOptionsResponse
Returns display information for a options response object.
The display information returned by this method indicates, that only headers, but no response body, should be send.
Parameters
processPropFindResponse
Returns display information for a prop find response object.
The display information generated by this response contains the post processed $response and a DOMDocument representing the XML response body.
This method utilizes ezcWebdavServer::getInstance()->xmlTool to perform basic XML operations, so this is the place to perform such changeds. You should overwrite this method, if your client has problems specifically with the
ezcWebdavPropFindResponse response.
Parameters
processPropPatchResponse
Returns display information for a prop patch response object.
The display information returned by this method indicates, that only headers, but no response body, should be send.
Parameters
processPropStatResponse
Returns display information for a prop stat response object.
The display information generated by this response contains the post processed $response and a DOMDocument representing the XML response body.
This method utilizes ezcWebdavServer::getInstance()->xmlTool to perform basic XML operations, so this is the place to perform such changeds. You should overwrite this method, if your client has problems specifically with the
ezcWebdavErrorResponse response.
Parameters
processPutResponse
Returns display information for a put response object.
The display information returned by this method indicates, that only headers, but no response body, should be send.
Parameters
retreiveBody
string retreiveBody(
)
Returns the body content of the request.
This method mainly exists for unit testing purpose. It reads the request body and returns the contents as a string. This method can also be usefull to be overriden during inheritence to filter the body of missbehaving WebDAV clients.
sendResponse
Finally send out the response.
This method is called to finally send the response to the browser. It can be overwritten in test cases to change the behaviour of printing out the result and sending the headers.
Parameters
Last updated: Mon, 12 Nov 2007