]> granicus.if.org Git - php/commitdiff
define php_ap_map_http_request_error function for older httpd only
authorZheng SHAO <z-shao@colopl.co.jp>
Thu, 29 Dec 2016 04:00:31 +0000 (13:00 +0900)
committerZheng SHAO <z-shao@colopl.co.jp>
Thu, 29 Dec 2016 07:07:05 +0000 (16:07 +0900)
sapi/apache2handler/sapi_apache2.c

index 9e9b853e1c6d94bd52058b6f701844dcf97229c1..81574a47843c84b546d77d1224e4ac79b1159cc2 100644 (file)
@@ -69,27 +69,32 @@ char *apache2_php_ini_path_override = NULL;
 ZEND_TSRMLS_CACHE_DEFINE()
 #endif
 
-int
-php_ap_map_http_request_error(apr_status_t rv, int status)
+/* if apache's version is newer than 2.2.31 or 2.4.16 */
+#if MODULE_MAGIC_COOKIE == 0x41503232UL && AP_MODULE_MAGIC_AT_LEAST(20051115,40) || \
+       MODULE_MAGIC_COOKIE == 0x41503234UL && AP_MODULE_MAGIC_AT_LEAST(20120211,47)
+#define php_ap_map_http_request_error ap_map_http_request_error
+#else
+static int php_ap_map_http_request_error(apr_status_t rv, int status)
 {
-    switch (rv) {
-    case AP_FILTER_ERROR: {
-        return AP_FILTER_ERROR;
-    }
-    case APR_ENOSPC: {
-        return HTTP_REQUEST_ENTITY_TOO_LARGE;
-    }
-    case APR_ENOTIMPL: {
-        return HTTP_NOT_IMPLEMENTED;
-    }
-    case APR_ETIMEDOUT: {
-        return HTTP_REQUEST_TIME_OUT;
-    }
-    default: {
-        return status;
-    }
-    }
+       switch (rv) {
+       case AP_FILTER_ERROR: {
+               return AP_FILTER_ERROR;
+       }
+       case APR_ENOSPC: {
+               return HTTP_REQUEST_ENTITY_TOO_LARGE;
+       }
+       case APR_ENOTIMPL: {
+               return HTTP_NOT_IMPLEMENTED;
+       }
+       case APR_ETIMEDOUT: {
+               return HTTP_REQUEST_TIME_OUT;
+       }
+       default: {
+               return status;
+       }
+       }
 }
+#endif
 
 static size_t
 php_apache_sapi_ub_write(const char *str, size_t str_length)
@@ -229,17 +234,6 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes)
                len = count_bytes - tlen;
        }
 
-// Apache 2.2.31 or 2.4.16 above
-#if MODULE_MAGIC_COOKIE == 0x41503232UL && AP_MODULE_MAGIC_AT_LEAST(20051115,40) || \
-       MODULE_MAGIC_COOKIE == 0x41503234UL && AP_MODULE_MAGIC_AT_LEAST(20120211,47)
-       if (ret != APR_SUCCESS) {
-               if (APR_STATUS_IS_TIMEUP(ret)) {
-                       SG(sapi_headers).http_response_code = ap_map_http_request_error(ret, HTTP_REQUEST_TIME_OUT);
-               } else {
-                       SG(sapi_headers).http_response_code = ap_map_http_request_error(ret, HTTP_BAD_REQUEST);
-               }
-       }
-#else
        if (ret != APR_SUCCESS) {
                if (APR_STATUS_IS_TIMEUP(ret)) {
                        SG(sapi_headers).http_response_code = php_ap_map_http_request_error(ret, HTTP_REQUEST_TIME_OUT);
@@ -247,7 +241,6 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes)
                        SG(sapi_headers).http_response_code = php_ap_map_http_request_error(ret, HTTP_BAD_REQUEST);
                }
        }
-#endif
 
        return tlen;
 }