cvs: presentations / webdav.xml /slides/webdav GET_1.xml GET_2.xml PUT_1.xml PUT_2.xml PUT_3.xml baseclass.xml extend_class.xml how_does_it_work.xml
sample_request.xml webdav_levels.xml what_is_webdav.xml why_php.xml /slides/webdav/examples GET1 GET1.php GET2.php PUT1.php PUT2.php request.xml
response.xml

From: Date: Thu, 11 Dec 2003 20:05:30 +0000
Subject: cvs: presentations / webdav.xml /slides/webdav GET_1.xml GET_2.xml PUT_1.xml PUT_2.xml PUT_3.xml baseclass.xml extend_class.xml how_does_it_work.xml
sample_request.xml webdav_levels.xml what_is_webdav.xml why_php.xml /slides/webdav/examples GET1 GET1.php GET2.php PUT1.php PUT2.php request.xml
response.xml
Groups: php.pres 
Request: Send a blank email to pres+get-914@lists.php.net to get a copy of this message
hholzgra Thu Dec 11 15:05:30 2003 EDT Added files: /presentations webdav.xml /presentations/slides/webdav GET_1.xml GET_2.xml PUT_1.xml PUT_2.xml PUT_3.xml baseclass.xml extend_class.xml how_does_it_work.xml sample_request.xml webdav_levels.xml what_is_webdav.xml why_php.xml /presentations/slides/webdav/examples GET1 GET1.php GET2.php PUT1.php PUT2.php request.xml response.xml Log: my apachecon webdav slides (converted from original PDF, work in progress)

Index: presentations/webdav.xml +++ presentations/webdav.xml <presentation> <title>WebDAV server implementation with Apache and PHP</title> <event>ApacheCon US 2003</event> <location>Las Vegas, NV</location> <date>Nov 18, 2003</date> <speaker>Hartmut Holzgraefe</speaker> <navmode>html</navmode> <basefontsize>12pt</basefontsize> <topic>WebDAV</topic> <slide>slides/webdav/what_is_webdav.xml</slide> <slide>slides/webdav/how_does_it_work.xml</slide> <slide>slides/webdav/sample_request.xml</slide> <slide>slides/webdav/why_php.xml</slide> <slide>slides/webdav/baseclass.xml</slide> <slide>slides/webdav/extend_class.xml</slide> <slide>slides/webdav/webdav_levels.xml</slide> <slide>slides/webdav/GET_1.xml</slide> <slide>slides/webdav/GET_2.xml</slide> <slide>slides/webdav/PUT_1.xml</slide> <slide>slides/webdav/PUT_2.xml</slide> <slide>slides/webdav/PUT_3.xml</slide> </presentation> Index: presentations/slides/webdav/GET_1.xml +++ presentations/slides/webdav/GET_1.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Getting content with %GET()%</title> <blurb> A WebDAV %GET% request can be handled similar to a normal HTTP %GET% request. Just make sure that you always set appropriate %Content-Length:% and %Last-Modified:% headers before returning the actual content. </blurb> <blurb> The path of the requested resource is passed to %GET()% in the parameter element '%path%': </blurb> <example filename="examples/GET1.php" fontsize="1em"/> </slide> Index: presentations/slides/webdav/GET_2.xml +++ presentations/slides/webdav/GET_2.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>%GET()% (cont.)</title> <blurb> As an alternative you may just return a readable PHP stream together with size and modification time information from the %GET()% method. By doing so you do not have to deal with HTTP header generation yourself and get support for partial %GET% requests without taking further action as an additional benefit. </blurb> <example fontsize="1em" filename="examples/GET2.php"/> <blurb> Note that no further error checking is needed on calling %fopen()% here. The base class will take appropriate action if the returned stream is not a PHP resource or not readable. </blurb> </slide> Index: presentations/slides/webdav/PUT_1.xml +++ presentations/slides/webdav/PUT_1.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Storing content with %PUT()%</title> <blurb> The HTTP %PUT% request method is used to write data to a resource on the server. The %PUT()% method is called by the base class with the following elements of its parameter array filled: </blurb> <list> <li>'%path%': the resource the received data should be put into</li> <li>'%content_length%': the number of bytes transfered</li> <li>'%content_type%': the content type of the data transfered</li> <li>'%stream%': a PHP stream you can read the actual data from</li> <li>'%ranges%': an array of byte range specifications to be written on partial requests</li> </list> <blurb> As with the %GET()% method you may either handle a %PUT% request yourself or just return a writable stream and have the base class write to it. </blurb> </slide> Index: presentations/slides/webdav/PUT_2.xml +++ presentations/slides/webdav/PUT_2.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>%PUT()% (cont.)</title> <blurb> </blurb> <example fontsize="1em" filename="examples/PUT1.php"/> </slide> Index: presentations/slides/webdav/PUT_3.xml +++ presentations/slides/webdav/PUT_3.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>%PUT()% (cont.)</title> <example fontsize="1em" filename="examples/PUT2.php"/> </slide> Index: presentations/slides/webdav/baseclass.xml +++ presentations/slides/webdav/baseclass.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>The WebDAV base class</title> <blurb title="The abstract %HTTP_WebDAV_Server% base class"> The actual PHP framework for writing a customized WebDAV server is implemented as an abstract base class. </blurb> <blurb> The class already takes care of most of the protocol specific stuff like: </blurb> <list> <li> HTTP header parsing </li> <li> XML parsing and generation </li> <li> authentication </li> <li> type conversions </li> <li> status codes </li> <li> lock checks </li> <li> the %OPTIONS% reply </li> <li> partial %GET% and %PUT% requests </li> <li> known client 'issues' </li> <li> ... </li> </list> </slide> Index: presentations/slides/webdav/extend_class.xml +++ presentations/slides/webdav/extend_class.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Extending the base class</title> <blurb> Extending the base class requires that you add methods to it that map to WebDAV specific request methods. These methods receive and return all relevant information in the form of PHP arrays. You do not have to deal with XML and header parsing / generation as this is already taken care of by the baseclass. </blurb> <list title="Possible methods"> <li>%GET()%</li> <li>%PUT()%</li> <li>%COPY()%</li> <li>%MOVE()%</li> <li>%DELETE()%</li> <li>%PROPFIND()%</li> <li>%PROPPATCH()%</li> <li>%LOCK()%</li> <li>%UNLOCK()%</li> <li>%CHECKLOCK()%</li> <li>%CHECKAUTH()%</li> </list> </slide> Index: presentations/slides/webdav/how_does_it_work.xml +++ presentations/slides/webdav/how_does_it_work.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>How does it work?</title> <list> <li> Layered on HTTP/1.1 using its extension facilities </li> <li> New methods, for example: %COPY%, %MKCOL%, %PROPFIND%, %CHECKOUT% </li> <li> New headers </li> <li> Some slight changes to existing methods semantics </li> <li> RFC 2518 ("core"): pretty straight-forward </li> <li> RFC 3253 (versioning): complex </li> </list> </slide> Index: presentations/slides/webdav/sample_request.xml +++ presentations/slides/webdav/sample_request.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>A sample request</title> <example fontsize="1em" title="Request all metadata for a directory and its contents" filename="examples/request.xml"/> <example fontsize="1em" title="Shortened response" filename="examples/response.xml"/> </slide> Index: presentations/slides/webdav/webdav_levels.xml +++ presentations/slides/webdav/webdav_levels.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>WebDAV conformance levels</title> <blurb title="For a minimal Server"> you only need to implement %GET()%, %PUT()% and %PROPFIND()%. Such a minimal server is not at all compliant to the sepcs but may already work with some clients. </blurb> <blurb title="For a DAV level 1 compliant server"> you also need %COPY()%, %MOVE()%, %DELETE()% and %PROPPATCH()%. </blurb> <blurb title="A DAV level 2 complient server"> has to implement locking, so you also need %LOCK()%, %UNLOCK()% and %CHECKLOCK()%. </blurb> <blurb title="A versioning server"> as specified in RFC 3253 is beyond the current scope of the this PHP package. </blurb> </slide> Index: presentations/slides/webdav/what_is_webdav.xml +++ presentations/slides/webdav/what_is_webdav.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>What is WebDAV?</title> <list> <li> *Web-based Distributed Authoring and Versioning* </li> <li> Goal: enable *interoperability* of tools for distributed web authoring </li> <li> Turns the web into a *writable* medium </li> <li> Applies to all kinds of content - not just HTML and images </li> <li> Based on extensions to HTTP </li> <li> Uses XML for properties, control, status </li> <li> RFC 2518 (Core) and RFC 3253 (DeltaV) </li> </list> </slide> Index: presentations/slides/webdav/why_php.xml +++ presentations/slides/webdav/why_php.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Why PHP?</title> <list title="Why PHP? Why not just use Apache %mod_dav%?"> <li> no additional binaries needed, just pure PHP code </li> <li> not necessarily bound to a single server or API </li> <li> easy to extend </li> <li> all needed bits included (XML parser, HTTP header and content access ...) </li> </list> </slide> Index: presentations/slides/webdav/examples/GET1.php +++ presentations/slides/webdav/examples/GET1.php <?php function GET(&$param) { $fspath = $this->base . $param["path"]; if (file_exists($fspath)) { header("Content-Type: " . mime_content_type($fspath); header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fspath)) . "GMT"); header("Content-Length: ". filesize($fspath)); readfile($fspath); return true; } else { return false; } } ?> Index: presentations/slides/webdav/examples/GET2.php +++ presentations/slides/webdav/examples/GET2.php <?php function GET(&$param) { $fspath = $this->base . $param["path"]; if (file_exists($fspath)) { $param['mimetype'] = mime_content_type($fspath); $param['mtime'] = filemtime($fspath); $param['size'] = filesize($fspath); $param['stream'] = fopen($fspath, "r"); return true; } else { return false; } } ?> Index: presentations/slides/webdav/examples/PUT1.php +++ presentations/slides/webdav/examples/PUT1.php <?php function PUT(&$params) { $fspath = $this->base . $params["path"]; if(!@is_dir(dirname($fspath))) { return "409 Conflict"; } $new = ! file_exists($fspath); $fp = fopen($fspath, "w"); if(is_resource($fp) && is_resource($params["stream"])) { while(!feof($params["stream"])) { fwrite($fp, fread($params["stream"], 4096)); } fclose($fp); } return $new ? "201 Created" : "204 No Content"; } ?> Index: presentations/slides/webdav/examples/PUT2.php +++ presentations/slides/webdav/examples/PUT2.php <?php // new approach to PUT function PUT(&$params) { $fspath = $this->base . $params["path"]; if(!@is_dir(dirname($fspath))) { return false; } $options["new"] = ! file_exists($fspath); $fp = fopen($fspath, "w"); return $fp; } ?> Index: presentations/slides/webdav/examples/request.xml +++ presentations/slides/webdav/examples/request.xml PROPFIND /container/ HTTP/1.1 Host: www.foo.bar Depth: 1 Content-Type: text/xml; charset="utf-8" Content-Length: ... <?xml version="1.0" ?> <D:propfind xmlns:D="DAV:"> <D:allprop/> </D:propfind> Index: presentations/slides/webdav/examples/response.xml +++ presentations/slides/webdav/examples/response.xml HTTP/1.1 207 Multi-Status Content-Type: text/xml; charset="utf-8" Content-Length: ... <?xml version="1.0" encoding="utf-8" ?> <D:multistatus xmlns:D="DAV:"> <D:response> <D:href>http://www.foo.bar/container/</D:href> <D:propstat> <D:prop> <D:getcontentlength>12345</getcontentlength> </D:prop> <D:prop xmlns:R="http://www.foo.bar/boxschema/"> <R:bigbox> <R:BoxType>Box type A</R:BoxType> </R:bigbox> <R:author> ...
« previous php.pres (#914) next »