Hi folks,
I've recently played with CouchDB, which is a document database with a
RESTful HTTP interface.
I noticed, however, that there is no way to prevent PHP from throwing
a warning on response codes other than 200, 206, 301, 302 and 303.
Something like 201 Created throws a warning, for example.
But I'm not sure if simply adding that one to the list is the proper
way forward, as I imagine there are many situations when you just want
to get the response content and look at the headers afterwards (w/
stream_get_meta_data). So I looked at the code and came up with this
change for http_fopen_wrapper.c line 547 (http://lxr.php.net/source/php-src/ext/standard/http_fopen_wrapper.c#547
):
if ((options & STREAM_ONLY_GET_HEADERS) ||
(php_stream_context_get_option(context, "http", "ignore_errors",
&tmpzval) == SUCCESS && Z_TYPE_PP(tmpzval) == IS_BOOL &&
Z_BVAL(retval))) {
So when the option "ignore_errors" is set for HTTP on the context, no
error will be thrown, and the response body is returned properly.
Is that a reasonable idea? I'm not entirely sure about the
"ignore_errors" name, maybe someone has a better suggestion.
I'd be happy to supply a full patch, but I wanted to hear if anyone
has thoughts on this first.
Cheers,
David
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php