Author: ts
Date: Mon Sep 24 11:11:54 2007
New Revision: 6242
Log:
- Added serialization of PROPPATCH response.
- Updated ezcWebdavDisplayInformation struct to be able to hold strings as the
body.
- Added a todo about that.
Added:
trunk/Webdav/tests/clients/rfc/proppatch/response/result.ser
Modified:
trunk/Webdav/docs/TODO
trunk/Webdav/src/structs/display_information.php
trunk/Webdav/src/transport.php
Modified: trunk/Webdav/docs/TODO
==============================================================================
--- trunk/Webdav/docs/TODO [iso-8859-1] (original)
+++ trunk/Webdav/docs/TODO [iso-8859-1] Mon Sep 24 11:11:54 2007
@@ -24,3 +24,7 @@
- Memory backend does not support emulation of client test case rfc/proppatch.
- Error emulation would need to be highly more flexible.
+
+- ezcWebdavDisplayInformation holds a DOMDocument as the body information per
+ default. Only the ezcWebdavGetResourceResponse needs it different. We
+ currently store both datatypes an $body, but that is unclean.
Modified: trunk/Webdav/src/structs/display_information.php
==============================================================================
--- trunk/Webdav/src/structs/display_information.php [iso-8859-1] (original)
+++ trunk/Webdav/src/structs/display_information.php [iso-8859-1] Mon Sep 24
11:11:54 2007
@@ -42,10 +42,11 @@
public $response;
/**
- * DOMDocument representing the response body.
- * Should be empty, if no body should be send.
+ * Representation of the response body.
+ * Should be null, if no body is to be sent, an instance of DOMDocument to
+ * send and XML body or a string representng the body if it is non-XML.
*
- * @var DOMDocument|null
+ * @var DOMDocument|string|null
*/
public $body;
}
Modified: trunk/Webdav/src/transport.php
==============================================================================
--- trunk/Webdav/src/transport.php [iso-8859-1] (original)
+++ trunk/Webdav/src/transport.php [iso-8859-1] Mon Sep 24 11:11:54 2007
@@ -1068,8 +1068,8 @@
$displayInfo = $this->processOptionsResponse( $response );
break;
case 'ezcWebdavPropPatchResponse':
- // $displayInfo = $this->processPropPatchResponse( $response );
- // break;
+ $displayInfo = $this->processPropPatchResponse( $response );
+ break;
case 'ezcWebdavGetResourceResponse':
case 'ezcWebdavHeadResponse':
case 'ezcWebdavMakeCollectionResponse':
@@ -1089,18 +1089,41 @@
* can be overwritten in test cases to change the behaviour of printing out
* the result and sending the headers.
*
- * @param ezcWebdavResponse $response
- * @param DOMDocument $dom
+ * @param ezcWebdavDisplayInformation $info
* @return void
+ *
+ * @todo Do we need to explicitly send Content-Length here?
*/
protected function sendResponse( ezcWebdavDisplayInformation $info )
{
+ switch ( true )
+ {
+ case ( $info->body instanceof DOMDocument ):
+ $info->body->formatOutput = true;
+ $result = $info->body->saveXML( $info->body );
+ break;
+ case ( is_string( $info->body ) ):
+ $result = $info->body;
+ break;
+ case ( $info->body === null ):
+ default:
+ $result = '';
+ break;
+ }
+
+ // Sends HTTP response code and description
header( (string) $info->response );
- if ( $info->body instanceof DOMDocument )
- {
- $info->body->formatOutput = true;
- echo $info->body->saveXML( $info->body );
- }
+
+ // Send headers defined by response
+ $headers = $info->repsonse->getHeaders();
+ foreach ( $headers as $name => $value )
+ {
+ header( "{$name}: {$value}" );
+ }
+
+ // Do we need to explictly send the Content-Length header here?
+
+ // All done
}
/**
@@ -1152,6 +1175,17 @@
);
}
return new ezcWebdavDisplayInformation( $response, $dom );
+ }
+
+ /**
+ * Returns an XML representation of the given response object.
+ *
+ * @param ezcWebdavPropPatchResponse $response
+ * @return DOMDocument
+ */
+ protected function processPropPatchResponse( ezcWebdavPropPatchResponse
$response )
+ {
+ return new ezcWebdavDisplayInformation( $response, null );
}
/**
Added: trunk/Webdav/tests/clients/rfc/proppatch/response/result.ser
==============================================================================
--- trunk/Webdav/tests/clients/rfc/proppatch/response/result.ser (added)
+++ trunk/Webdav/tests/clients/rfc/proppatch/response/result.ser [iso-8859-1]
Mon Sep 24 11:11:54 2007
@@ -1,0 +1,1 @@
+a:2:{s:7:"headers";a:1:{i:0;s:15:"HTTP/1.1 200 OK";}s:4:"body";N;}
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components