summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/SAPI.c31
-rw-r--r--main/SAPI.h1
-rw-r--r--main/main.c3
3 files changed, 25 insertions, 10 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index fd38e7cdd5..19e2672dfe 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -278,9 +278,11 @@ SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len TSRMLS_DC
/*
* Called from php_request_startup() for every request.
*/
-SAPI_API void sapi_activate(TSRMLS_D)
+SAPI_API void sapi_activate_headers_only(TSRMLS_D)
{
- void (*post_reader_func)(TSRMLS_D);
+ if (SG(request_info).headers_read == 1)
+ return;
+ SG(request_info).headers_read = 1;
zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0);
SG(sapi_headers).send_default_content_type = 1;
@@ -289,8 +291,6 @@ SAPI_API void sapi_activate(TSRMLS_D)
*/
SG(sapi_headers).http_status_line = NULL;
SG(headers_sent) = 0;
- SG(read_post_bytes) = 0;
- SG(request_info).post_data = NULL;
SG(request_info).current_user = NULL;
SG(request_info).current_user_length = 0;
SG(request_info).no_headers = 0;
@@ -303,6 +303,23 @@ SAPI_API void sapi_activate(TSRMLS_D)
} else {
SG(request_info).headers_only = 0;
}
+ if (SG(server_context)) {
+ SG(request_info).cookie_data = sapi_module.read_cookies(TSRMLS_C);
+ if (sapi_module.activate) {
+ sapi_module.activate(TSRMLS_C);
+ }
+ }
+}
+
+SAPI_API void sapi_activate(TSRMLS_D)
+{
+ void (*post_reader_func)(TSRMLS_D);
+ SG(headers_sent) = 0;
+ SG(read_post_bytes) = 0;
+ SG(request_info).post_data = NULL;
+ /* It's possible to override this general case in the activate() callback, if
+ * necessary.
+ */
SG(rfc1867_uploaded_files) = NULL;
if (SG(server_context)) {
@@ -337,10 +354,7 @@ SAPI_API void sapi_activate(TSRMLS_D)
} else {
SG(request_info).content_type_dup = NULL;
}
- SG(request_info).cookie_data = sapi_module.read_cookies(TSRMLS_C);
- if (sapi_module.activate) {
- sapi_module.activate(TSRMLS_C);
- }
+ sapi_activate_headers_only(TSRMLS_C);
}
}
@@ -383,6 +397,7 @@ SAPI_API void sapi_deactivate(TSRMLS_D)
}
sapi_send_headers_free(TSRMLS_C);
SG(sapi_started) = 0;
+ SG(request_info).headers_read = 0;
}
diff --git a/main/SAPI.h b/main/SAPI.h
index a1f216f6a4..df8cab00e5 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -83,6 +83,7 @@ typedef struct {
zend_bool headers_only;
zend_bool no_headers;
+ zend_bool headers_read;
sapi_post_entry *post_entry;
diff --git a/main/main.c b/main/main.c
index 938b24bcf0..c95af4c332 100644
--- a/main/main.c
+++ b/main/main.c
@@ -896,7 +896,7 @@ int php_request_startup_for_hook(TSRMLS_D)
return FAILURE;
php_output_activate(TSRMLS_C);
- sapi_activate(TSRMLS_C);
+ sapi_activate_headers_only(TSRMLS_C);
php_hash_environment(TSRMLS_C);
return retval;
@@ -958,7 +958,6 @@ void php_request_shutdown_for_hook(void *dummy)
void php_request_shutdown(void *dummy)
{
TSRMLS_FETCH();
-
zend_try {
php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1) TSRMLS_CC);
} zend_end_try();