]> granicus.if.org Git - php/commitdiff
- Changed HTTP stream wrapper to accept any code between and including
authorMichael Wallner <mike@php.net>
Fri, 25 Jul 2008 08:27:37 +0000 (08:27 +0000)
committerMichael Wallner <mike@php.net>
Fri, 25 Jul 2008 08:27:37 +0000 (08:27 +0000)
  200 to 399 as successful. (patch by Noah Fontes)

NEWS
ext/standard/http_fopen_wrapper.c

diff --git a/NEWS b/NEWS
index 8a9e422f95fda02ad7be6a53b7ef64cbb0efbdac..49dab9d75558fd57bb252c3a952dac07ae1de5e2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ PHP                                                                        NEWS
 - Changed PCRE, SPL and reflection extensions to always be enabled. (Marcus)
 - Changed md5() to use improved implementation. (Solar Designer, Dmitry)
 - Changed mhash to be a wrapper layer around the hash extension. (Scott)
+- Changed HTTP stream wrapper to accept any code between and including
+  200 to 399 as successful. (Mike, Noah Fontes)
 
 - Improved PHP syntax and semantics:
   . Added lambda functions and closures (Christian Seiler, Dmitry)
index 0140f2e94a4083c691de3388f1df88322b9f34ba..a228dceaf9a48632a87224739b95305b35947c4e 100644 (file)
@@ -529,25 +529,25 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
                                (context && php_stream_context_get_option(context, "http", "ignore_errors",  &tmpzval) == SUCCESS && zend_is_true(*tmpzval)) ) {
                                reqok = 1;
                        }
-                       switch(response_code) {
-                               case 200:
-                               case 206: /* partial content */
-                               case 302:
-                               case 303:
-                               case 301:
-                                       reqok = 1;
-                                       break;
-                               case 403:
-                                       php_stream_notify_error(context, PHP_STREAM_NOTIFY_AUTH_RESULT,
-                                                       tmp_line, response_code);
-                                       break;
-                               default:
-                                       /* safety net in the event tmp_line == NULL */
-                                       if (!tmp_line_len) {
-                                               tmp_line[0] = '\0';
-                                       }
-                                       php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE,
-                                                       tmp_line, response_code);
+                       /* all status codes in the 2xx range are defined by the specification as successful;
+                        * all status codes in the 3xx range are for redirection, and so also should never
+                        * fail */
+                       if (response_code >= 200 && response_code < 400) {
+                               reqok = 1;
+                       } else {
+                               switch(response_code) {
+                                       case 403:
+                                               php_stream_notify_error(context, PHP_STREAM_NOTIFY_AUTH_RESULT,
+                                                               tmp_line, response_code);
+                                               break;
+                                       default:
+                                               /* safety net in the event tmp_line == NULL */
+                                               if (!tmp_line_len) {
+                                                       tmp_line[0] = '\0';
+                                               }
+                                               php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE,
+                                                               tmp_line, response_code);
+                               }
                        }
                        if (tmp_line[tmp_line_len - 1] == '\n') {
                                --tmp_line_len;