HTTP streams, status codes & WebDAV

php.internals

Jared Williams

21 years ago
Hi, Was hoping to use PHP streams API to query a WebDAV server, something along the lines of.. $context = stream_context_create( array( 'http' => array('method' => 'PROPFIND') ) ); $f = fopen('http://localhost/WebDav/', 'r', FALSE, $context); fpassthru($f); fclose($f); but the streams API seems overly strict on status codes returned, a succesful PROPFIND is meant to return a 207 status code, but the HTTP stream wrapper isn't treating it as such, throwing an error, and failing to open. Is this a bug? Jared

Sara Golemon

21 years ago
> Was hoping to use PHP streams API to query a WebDAV server, something > along the lines of.. > > $context = stream_context_create( > array( > 'http' => > array('method' => 'PROPFIND') > ) > ); > $f = fopen('http://localhost/WebDav/', 'r', FALSE, $context); > > fpassthru($f); > fclose($f); > > but the streams API seems overly strict on status codes returned, a > succesful PROPFIND is meant to return a 207 status code, but the > HTTP stream wrapper isn't treating it as such, throwing an error, and > failing to open. Is this a bug? >
Short Answer: http://pear.php.net/package/HTTP_WebDAV_Client Long Answer: Although the content is tossed out, you can see the status codes and any other headers in $http_response_header whether the http request returned a "valid" response code or not. That said, a context option to optionally accept additional response codes *may* be in order. -Sara

Hartmut Holzgraefe

21 years ago
Sara Golemon wrote:
> That said, a context option to optionally accept additional response codes > *may* be in order.
esp. as all 2xx codes are meant to be success codes
-- Hartmut Holzgraefe <hartmut@php.net>