Skip to content

Commit d92606a

Browse files
author
Zheng SHAO
committed
add old versions of httpd support
1 parent 884e2a0 commit d92606a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

sapi/apache2handler/sapi_apache2.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,28 @@ char *apache2_php_ini_path_override = NULL;
6969
ZEND_TSRMLS_CACHE_DEFINE()
7070
#endif
7171

72+
int
73+
php_ap_map_http_request_error(apr_status_t rv, int status)
74+
{
75+
switch (rv) {
76+
case AP_FILTER_ERROR: {
77+
return AP_FILTER_ERROR;
78+
}
79+
case APR_ENOSPC: {
80+
return HTTP_REQUEST_ENTITY_TOO_LARGE;
81+
}
82+
case APR_ENOTIMPL: {
83+
return HTTP_NOT_IMPLEMENTED;
84+
}
85+
case APR_ETIMEDOUT: {
86+
return HTTP_REQUEST_TIME_OUT;
87+
}
88+
default: {
89+
return status;
90+
}
91+
}
92+
}
93+
7294
static size_t
7395
php_apache_sapi_ub_write(const char *str, size_t str_length)
7496
{
@@ -207,13 +229,25 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes)
207229
len = count_bytes - tlen;
208230
}
209231

232+
// Apache 2.2.31 or 2.4.16 above
233+
#if MODULE_MAGIC_COOKIE == 0x41503232UL && AP_MODULE_MAGIC_AT_LEAST(20051115,40) || \
234+
MODULE_MAGIC_COOKIE == 0x41503234UL && AP_MODULE_MAGIC_AT_LEAST(20120211,47)
210235
if (ret != APR_SUCCESS) {
211236
if (APR_STATUS_IS_TIMEUP(ret)) {
212237
SG(sapi_headers).http_response_code = ap_map_http_request_error(ret, HTTP_REQUEST_TIME_OUT);
213238
} else {
214239
SG(sapi_headers).http_response_code = ap_map_http_request_error(ret, HTTP_BAD_REQUEST);
215240
}
216241
}
242+
#else
243+
if (ret != APR_SUCCESS) {
244+
if (APR_STATUS_IS_TIMEUP(ret)) {
245+
SG(sapi_headers).http_response_code = php_ap_map_http_request_error(ret, HTTP_REQUEST_TIME_OUT);
246+
} else {
247+
SG(sapi_headers).http_response_code = php_ap_map_http_request_error(ret, HTTP_BAD_REQUEST);
248+
}
249+
}
250+
#endif
217251

218252
return tlen;
219253
}

0 commit comments

Comments
 (0)