summaryrefslogtreecommitdiff
path: root/sapi/apache2handler/sapi_apache2.c
diff options
context:
space:
mode:
authorZheng SHAO <z-shao@colopl.co.jp>2016-12-28 19:02:41 +0900
committerZheng SHAO <z-shao@colopl.co.jp>2016-12-29 00:41:56 +0900
commitd92606a4bee4381f6762a3cd157c304bea4934d0 (patch)
tree43fc4497df023527d34839410f8a65b3ccac5d29 /sapi/apache2handler/sapi_apache2.c
parent884e2a0519b15bdd552c25c658c2ff233ff53a81 (diff)
downloadphp-git-d92606a4bee4381f6762a3cd157c304bea4934d0.tar.gz
add old versions of httpd support
Diffstat (limited to 'sapi/apache2handler/sapi_apache2.c')
-rw-r--r--sapi/apache2handler/sapi_apache2.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c
index 1a4f36fa9e..9e9b853e1c 100644
--- a/sapi/apache2handler/sapi_apache2.c
+++ b/sapi/apache2handler/sapi_apache2.c
@@ -69,6 +69,28 @@ 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)
+{
+ 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;
+ }
+ }
+}
+
static size_t
php_apache_sapi_ub_write(const char *str, size_t str_length)
{
@@ -207,6 +229,9 @@ 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);
@@ -214,6 +239,15 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes)
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);
+ } else {
+ SG(sapi_headers).http_response_code = php_ap_map_http_request_error(ret, HTTP_BAD_REQUEST);
+ }
+ }
+#endif
return tlen;
}