Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33000 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44610 invoked by uid 1010); 1 Nov 2007 23:07:00 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 44595 invoked from network); 1 Nov 2007 23:07:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Nov 2007 23:07:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=dz@bitxtender.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dz@bitxtender.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain bitxtender.com from 80.237.132.12 cause and error) X-PHP-List-Original-Sender: dz@bitxtender.com X-Host-Fingerprint: 80.237.132.12 wp005.webpack.hosteurope.de Received: from [80.237.132.12] ([80.237.132.12:49127] helo=wp005.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B1/39-02860-21C5A274 for ; Thu, 01 Nov 2007 18:06:59 -0500 Received: from [85.183.90.3] (helo=[10.1.1.120]); authenticated by wp005.webpack.hosteurope.de running ExIM using esmtpsa (TLSv1:RC4-SHA:128) id 1Inj7n-0005kq-LG; Fri, 02 Nov 2007 00:06:55 +0100 Message-ID: <87A052F5-4285-4A16-8566-40DFB845C9B9@bitxtender.com> To: PHP Internals Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v912) Date: Fri, 2 Nov 2007 00:06:54 +0100 X-Mailer: Apple Mail (2.912) X-bounce-key: webpack.hosteurope.de;dz@bitxtender.com;1193958419;dc291f51; Subject: [Patch] http_fopen_wrapper.c and allowing any response code w/o warning From: dz@bitxtender.com (=?ISO-8859-1?Q?David_Z=FClke?=) 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