Skip to content

Commit 2b95b3c

Browse files
author
Sascha Schumann
committed
add a "force HTTP/1.0 response" facility to the SAPI layer
this is necessary, when you want to take over control of a connection and the web server is doing stupid things by default (like enabling chunked transfer encoding for no reason).
1 parent b9447c2 commit 2b95b3c

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

main/SAPI.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,15 @@ SAPI_API int sapi_get_fd(int *fd TSRMLS_DC)
860860
}
861861
}
862862

863+
SAPI_API int sapi_force_http_10(TSRMLS_D)
864+
{
865+
if (sapi_module.force_http_10) {
866+
return sapi_module.force_http_10(TSRMLS_C);
867+
} else {
868+
return -1;
869+
}
870+
}
871+
863872
/*
864873
* Local variables:
865874
* tab-width: 4

main/SAPI.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len TSRMLS_DC
187187
SAPI_API void sapi_activate_headers_only(TSRMLS_D);
188188

189189
SAPI_API int sapi_get_fd(int *fd TSRMLS_DC);
190+
SAPI_API int sapi_force_http_10(TSRMLS_D);
190191

191192
struct _sapi_module_struct {
192193
char *name;
@@ -228,7 +229,8 @@ struct _sapi_module_struct {
228229
int php_ini_ignore;
229230

230231
int (*get_fd)(int *fd TSRMLS_DC);
231-
232+
233+
int (*force_http_10)(TSRMLS_D);
232234
};
233235

234236

sapi/apache/mod_php4.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,17 @@ static int sapi_apache_get_fd(int *nfd TSRMLS_DC)
360360
}
361361
/* }}} */
362362

363+
/* {{{ sapi_apache_force_http_10
364+
*/
365+
static int sapi_apache_force_http_10(TSRMLS_D)
366+
{
367+
request_rec *r = SG(server_context);
368+
369+
r->proto_num = HTTP_VERSION(1,0);
370+
371+
return 0;
372+
}
373+
363374
/* {{{ sapi_module_struct apache_sapi_module
364375
*/
365376
static sapi_module_struct apache_sapi_module = {
@@ -403,7 +414,8 @@ static sapi_module_struct apache_sapi_module = {
403414
NULL, /* treat data */
404415
NULL, /* exe location */
405416
0, /* ini ignore */
406-
sapi_apache_get_fd
417+
sapi_apache_get_fd,
418+
sapi_apache_force_http_10
407419
};
408420
/* }}} */
409421

0 commit comments

Comments
 (0)