Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcWebdavTransport

Webdav::ezcWebdavTransport

Class ezcWebdavTransport

Transport layer mainclass that implements RFC compliant client communication.

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. An exception are LOCK related requests, which will be handled by a plugin.

To adjust this base transport layer main class to the needs of RFC-2518-inconform client implementations, there is the powerful 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 paths (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:

Source for this file: /Webdav/src/transport.php

Version:   //autogentag//
Link:   RFC 2518

Descendants

Child Class Description
ezcWebdavKonquerorCompatibleTransport Transport layer for the Konqueror web browser (KDE).
ezcWebdavMicrosoftCompatibleTransport Transport layer for Microsoft clients with RFC incompatiblities.

Constants

VERSION = '//autogentag//' Used for server software string in Server header.

Member Variables

public static array(string=>string) $handlingMap
Map of response objects to handling methods.

Need public access here to retrieve this in ezcWebdavPluginRegistry.

public static array(string=>string) $parsingMap
Map of HTTP methods to object method names for parsing.

Need public access here to retrieve this in ezcWebdavPluginRegistry.

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 for a collection.
protected ezcWebdavStringDisplayInformation processGetResourceResponse( $response )
Returns display information for a get response on a non-collection.
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 string retrieveBody( )
Returns the body content of the request.
protected string retrievePath( $uri )
Returns the translated request path.
protected void sendResponse( $output )
Finally sends out the response.

Methods

flattenResponse

Flattens a processed response object to headers and body.

Takes a given ezcWebdavDisplayInformation object and returns an array containg the headers and body it represents.

The returned information can be processed (send out to the client) by ezcWebdavTransport::sendResponse().

Parameters:
Name Type Description
$info ezcWebdavDisplayInformation
Exceptions:
Type Description
ezcWebdavInvalidHeaderException if the generated result is an ezcWebdavEmptyDisplayInformation and the contained ezcWebdavResponse object has a Content-Type or a Content-Length header set.
ezcWebdavMissingHeaderException if the generated result is an ezcWebdavStringDisplayInformation struct and the contained ezcWebdavResponse object has no Content-Type header set.
Redefined in descendants as:
Method Description
ezcWebdavMicrosoftCompatibleTransport::flattenResponse() Flattens a processed response object to headers and body. 

handleException

ezcWebdavErrorResponse handleException( $e , [string $uri = null] )

Handle a thrown exception and generate an error response from it.

Takes the given exception $e and generates a response object from it. The $uri parameter will be given to ezcWebdavErrorResponse::__construct().

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. NOTE: The plugin API is not public, yet, and will be part of a next release.

Parameters:
Name Type Description
$e Exception
$uri string

handleResponse

void handleResponse( ezcWebdavResponse $response )

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. NOTE: The plugin API is not public, yet, and will be part of a next release.

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:
Name Type Description
$response ezcWebdavResponse

parseCopyRequest

ezcWebdavCopyRequest parseCopyRequest( string $path , string $body )

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
Exceptions:
Type Description
ezcWebdavInvalidRequestBodyException if the body of the copy request is invalid (XML wise or RFC wise).

parseDeleteRequest

ezcWebdavDeleteRequest parseDeleteRequest( string $path , string $body )

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

ezcWebdavGetRequest parseGetRequest( string $path , string $body )

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 ezcWebdavGetResourceResponse object.

This method may be overwritten to adjust it to special client behaviour.

Parameters:
Name Type Description
$path string
$body string

parseHeadRequest

ezcWebdavHeadRequest parseHeadRequest( string $path , string $body )

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 ezcWebdavHeadRequest object.

This method may be overwritten to adjust it to special client behaviour.

Parameters:
Name Type Description
$path string
$body string

parseMakeCollectionRequest

ezcWebdavMakeCollectionRequest parseMakeCollectionRequest( string $path , string $body )

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

ezcWebdavMoveRequest parseMoveRequest( string $path , string $body )

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

ezcWebdavOptionsRequest parseOptionsRequest( string $path , string $body )

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

ezcWebdavCopyRequest|ezcWebdavMoveRequest parsePropertyBehaviourContent( $dom , ezcWebdavRequest $request )

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 extended transport easier.

Parameters:
Name Type Description
$dom DOMDocument
$request ezcWebdavRequest ezcWebdavCopyRequest or ezcWebdavMoveRequest

parsePropFindRequest

ezcWebdavPropFindRequest parsePropFindRequest( string $path , string $body )

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:
Method Description
ezcWebdavMicrosoftCompatibleTransport::parsePropFindRequest() Parses the PROPFIND request and returns a request object. 

parsePropPatchRequest

ezcWebdavPropPatchRequest parsePropPatchRequest( string $path , string $body )

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

ezcWebdavPutRequest parsePutRequest( string $path , string $body )

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 ezcWebdavPutRequest object.

This method may be overwritten to adjust it to special client behaviour.

Parameters:
Name Type Description
$path string
$body string

parseRequest

ezcWebdavRequest|ezcWebdavResponse parseRequest( string $uri )

Parses the incoming request into a fitting request abstraction object.

This method is the main entry point of ezcWebdavServer and is utilized by it to parse the incoming request into an instance of ezcWebdavRequest.

The submitted $uri must be formatted in a way, that the ezcWebdavPathFactory (by default this is ezcWebdavAutomaticPathFactory) can convert it into a path absolute to the base of the WebDAV repository.

The retrieval of the request body is performed by the retrieveBody() 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. NOTE: The plugin API is not public, yet, and will be part of a next release.

If an error occurs during request parsing, an instance of ezcWebdavResponse may be returned instead of an instance of ezcWebdavRequest. ezcWebdavServer will handle this correctly.

Parameters:
Name Type Description
$uri string

processCopyResponse

ezcWebdavEmptyDisplayInformation processCopyResponse( ezcWebdavCopyResponse $response )

Returns display information for a copy response object.

This method returns the display information generated for a $response object of type ezcWebdavCopyResponse. It returns an instance of ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.

The display information returned by this method indicates, that only headers, but no response body, should be send.

Parameters:
Name Type Description
$response ezcWebdavCopyResponse

processDeleteResponse

ezcWebdavEmptyDisplayInformation processDeleteResponse( ezcWebdavDeleteResponse $response )

Returns display information for a delete response object.

This method returns the display information generated for a $response object of type ezcWebdavDeleteResponse. It returns an instance of ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.

The display information returned by this method indicates, that only headers, but no response body, should be send.

Parameters:
Name Type Description
$response ezcWebdavDeleteResponse

processErrorResponse

ezcWebdavXmlDisplayInformation|ezcWebdavEmptyDisplayInformation processErrorResponse( ezcWebdavErrorResponse $response , [bool $xml = false] )

Returns display information for a error response object.

This method returns the display information generated for a $response object of type ezcWebdavErrorResponse. It returns an instance of ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.

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->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.
Redefined in descendants as:
Method Description
ezcWebdavKonquerorCompatibleTransport::processErrorResponse() Returns display information for a error response object. 

processGetCollectionResponse

ezcWebdavEmptyDisplayInformation processGetCollectionResponse( ezcWebdavGetCollectionResponse $response )

Returns display information for a get response for a collection.

This method returns the display information generated for a $response object of type ezcWebdavGetCollectionResponse. It returns an instance of ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.

The display information returned by this method indicates, that only headers, but no response body, should be send.

Parameters:
Name Type Description
$response ezcWebdavGetCollectionResponse

processGetResourceResponse

ezcWebdavStringDisplayInformation processGetResourceResponse( ezcWebdavGetResourceResponse $response )

Returns display information for a get response on a non-collection.

This method returns the display information generated for a $response object of type ezcWebdavGetResourceResponse. 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:
Name Type Description
$response ezcWebdavGetResourceResponse

processHeadResponse

ezcWebdavEmptyDisplayInformation processHeadResponse( ezcWebdavHeadResponse $response )

Returns display information for a head response object.

This method returns the display information generated for a $response object of type ezcWebdavHeadResponse. It returns an instance of ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.

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:
Name Type Description
$response ezcWebdavHeadResponse

processMakeCollectionResponse

ezcWebdavEmptyDisplayInformation processMakeCollectionResponse( ezcWebdavMakeCollectionResponse $response )

Returns display information for a make collection response object.

This method returns the display information generated for a $response object of type ezcWebdavMakeCollectionResponse. It returns an instance of ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.

The display information returned by this method indicates, that only headers, but no response body, should be send.

Parameters:
Name Type Description
$response ezcWebdavMakeCollectionResponse

processMoveResponse

ezcWebdavEmptyDisplayInformation processMoveResponse( ezcWebdavMoveResponse $response )

Returns display information for a move response object.

This method returns the display information generated for a $response object of type ezcWebdavMoveResponse. It returns an instance of ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.

The display information returned by this method indicates, that only headers, but no response body, should be send.

Parameters:
Name Type Description
$response ezcWebdavMoveResponse

processMultiStatusResponse

ezcWebdavXmlDisplayInformation processMultiStatusResponse( ezcWebdavMultistatusResponse $response )

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->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

ezcWebdavEmptyDisplayInformation processOptionsResponse( ezcWebdavOptionsResponse $response )

Returns display information for a options response object.

This method returns the display information generated for a $response object of type ezcWebdavOptionsResponse. It returns an instance of ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.

The display information returned by this method indicates, that only headers, but no response body, should be send.

Parameters:
Name Type Description
$response ezcWebdavOptionsResponse

processPropFindResponse

ezcWebdavXmlDisplayInformation processPropFindResponse( ezcWebdavPropFindResponse $response )

Returns display information for a prop find response object.

This method returns the display information generated for a $response object of type ezcWebdavPropFindResponse. 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->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:
Name Type Description
$response ezcWebdavPropFindResponse
Redefined in descendants as:
Method Description
ezcWebdavKonquerorCompatibleTransport::processPropFindResponse() Decodes the URLs in href attributes of PROPFIND responses. 

processPropPatchResponse

ezcWebdavEmptyDisplayInformation processPropPatchResponse( ezcWebdavPropPatchResponse $response )

Returns display information for a prop patch response object.

This method returns the display information generated for a $response object of type ezcWebdavPropPatchResponse. It returns an instance of ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.

The display information returned by this method indicates, that only headers, but no response body, should be send.

Parameters:
Name Type Description
$response ezcWebdavPropPatchResponse

processPropStatResponse

ezcWebdavXmlDisplayInformation processPropStatResponse( ezcWebdavPropStatResponse $response )

Returns display information for a prop stat response object.

This method returns the display information generated for a $response object of type ezcWebdavPropStatResponse. 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->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 ezcWebdavPropStatResponse response.

Parameters:
Name Type Description
$response ezcWebdavPropStatResponse

processPutResponse

ezcWebdavEmptyDisplayInformation processPutResponse( ezcWebdavPutResponse $response )

Returns display information for a put response object.

This method returns the display information generated for a $response object of type ezcWebdavPutResponse. It returns an instance of ezcWebdavDisplayInformation containing the post-processed response object and the appropriate body.

The display information returned by this method indicates, that only headers, but no response body, should be send.

Parameters:
Name Type Description
$response ezcWebdavPutResponse

retreiveBody

string retreiveBody( )

Returns the body content of the request.

This method is only kept for BC reasons. Please refer to retrieveBody().

retrieveBody

string retrieveBody( )

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.

retrievePath

string retrievePath( string $uri )

Returns the translated request path.

This method calls the configured path factory to translate the submitted $uri into a local path. It can be overwritten to perform client specific path adjustments.

Parameters:
Name Type Description
$uri string

sendResponse

void sendResponse( ezcWebdavOutputResult $output )

Finally sends out the response.

This method is called to finally send the response to the client. It can be overwritten in test cases to change the behaviour of printing out the result and sending the headers.

Parameters:
Name Type Description
$output ezcWebdavOutputResult
Documentation generated by phpDocumentor 1.4.3