# HTTP streams, status codes & WebDAV

- Thread: https://externals.io/message/15995
- Original archive: https://news-web.php.net/php.internals/15995
- Started by Jared Williams on 2005-04-18T14:11:37+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #15995 — Jared Williams — 2005-04-18T14:11:37+00:00

URL: https://externals.io/message/15995#15995

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

---

## #16007 — Sara Golemon — 2005-04-18T16:18:49+00:00

URL: https://externals.io/message/15995#16007 · In reply to: #15995

> 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

---

## #16008 — Hartmut Holzgraefe — 2005-04-18T16:38:48+00:00

URL: https://externals.io/message/15995#16008 · In reply to: #16007

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
