summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Schlossnagle <gschlossnagle@php.net>2002-08-28 18:56:51 +0000
committerGeorge Schlossnagle <gschlossnagle@php.net>2002-08-28 18:56:51 +0000
commit2bc1d055cb8046699f10bad45ea5e479b47fbf24 (patch)
tree887824e874a17776c0779ddab1a01aeb351e18ae
parent0a105b4130638fae983664a7556bf5843c1dd10a (diff)
downloadphp-git-2bc1d055cb8046699f10bad45ea5e479b47fbf24.tar.gz
Added wrapper functions for the majority of the apache API_EXPORT functions
as class methods for the ApacheRequest objects. broke sapi_activate into two functions to allow for reading of headers/cookies separately from request bodies (POST stuff). Altered some of the send_headers code in mod_php4.c to prevent sending headers twice (since a phpResponseHandler needs to be able to have full freedom for setting headers using the ap_*_header* functions.
-rw-r--r--main/SAPI.c31
-rw-r--r--main/SAPI.h1
-rw-r--r--main/main.c3
-rw-r--r--sapi/apache/mod_php4.c51
-rw-r--r--sapi/apache/mod_php4.h21
-rw-r--r--sapi/apache/php_apache.c267
-rw-r--r--sapi/apache/sapi_apache.c11
7 files changed, 329 insertions, 56 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();
diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c
index b907efb517..7a1ef095e1 100644
--- a/sapi/apache/mod_php4.c
+++ b/sapi/apache/mod_php4.c
@@ -349,10 +349,14 @@ static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
}
((request_rec *) SG(server_context))->status = SG(sapi_headers).http_response_code;
- /* check that we haven't sent headers already */
- if(!((request_rec *) SG(server_context))->sent_bodyct)
- send_http_header((request_rec *) SG(server_context));
- return SAPI_HEADER_SENT_SUCCESSFULLY;
+ /* check that we haven't sent headers already, we use our own
+ * headers_sent since we may send headers at anytime
+ */
+ if(!AP(headers_sent)) {
+ send_http_header((request_rec *) SG(server_context));
+ AP(headers_sent) = 1;
+ }
+ return SAPI_HEADER_SENT_SUCCESSFULLY;
}
/* }}} */
@@ -433,6 +437,7 @@ static void php_apache_log_message(char *message)
static void php_apache_request_shutdown(void *dummy)
{
TSRMLS_FETCH();
+ AP(current_hook) = AP_CLEANUP;
php_output_set_status(0 TSRMLS_CC);
SG(server_context) = NULL; /* The server context (request) is invalid by the time run_cleanups() is called */
if(SG(sapi_started)) {
@@ -443,6 +448,8 @@ static void php_apache_request_shutdown(void *dummy)
if(AP(setup_env)) {
AP(setup_env) = 0;
}
+ AP(current_hook) = AP_WAITING_FOR_REQUEST;
+ AP(headers_sent) = 0;
}
/* }}} */
@@ -1137,7 +1144,7 @@ static void php_init_handler(server_rec *s, pool *p)
}
/* }}} */
-static int php_run_hook(request_rec *r, char *handler)
+static int php_run_hook(char *handler, request_rec *r)
{
zval *ret = NULL;
php_per_dir_config *conf;
@@ -1171,27 +1178,26 @@ static int php_run_hook(request_rec *r, char *handler)
return HTTP_INTERNAL_SERVER_ERROR;
}
-int php_run_stacked_handler(char *hookname, request_rec *r) {
- return php_run_hook(r, hookname);
-}
static int php_uri_translation(request_rec *r)
{
php_per_server_config *conf;
fprintf(stderr,"HOOK: uri_translation\n");
+ AP(current_hook) = AP_URI_TRANS;
conf = (php_per_server_config *) get_module_config(r->server->module_config, &php4_module);
- return sapi_stack_apply_with_argument_stop_if_equals(&conf->uri_handlers, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_stacked_handler, r, OK);
+ return sapi_stack_apply_with_argument_stop_if_equals(&conf->uri_handlers, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r, OK);
}
static int php_header_hook(request_rec *r)
{
php_per_dir_config *conf;
fprintf(stderr,"HOOK: headers\n");
+ AP(current_hook) = AP_HEADER_PARSE;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php4_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->headers_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_stacked_handler,
+ (int (*)(void *element, void *)) php_run_hook,
r);
}
@@ -1199,10 +1205,11 @@ static int php_auth_hook(request_rec *r)
{
php_per_dir_config *conf;
fprintf(stderr,"HOOK: auth\n");
+ AP(current_hook) = AP_AUTHENTICATION;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php4_module);
return sapi_stack_apply_with_argument_stop_if_equals(&conf->auth_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_stacked_handler,
+ (int (*)(void *element, void *)) php_run_hook,
r, OK);
}
@@ -1210,10 +1217,11 @@ static int php_access_hook(request_rec *r)
{
php_per_dir_config *conf;
fprintf(stderr,"HOOK: access\n");
+ AP(current_hook) = AP_ACCESS_CONTROL;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php4_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->access_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_stacked_handler,
+ (int (*)(void *element, void *)) php_run_hook,
r);
}
@@ -1222,10 +1230,11 @@ static int php_type_hook(request_rec *r)
{
php_per_dir_config *conf;
fprintf(stderr,"HOOK: type-checker\n");
+ AP(current_hook) = AP_TYPE_CHECKING;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php4_module);
return sapi_stack_apply_with_argument_stop_if_equals(&conf->type_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_stacked_handler,
+ (int (*)(void *element, void *)) php_run_hook,
r, OK);
}
@@ -1233,10 +1242,11 @@ static int php_fixup_hook(request_rec *r)
{
php_per_dir_config *conf;
fprintf(stderr,"HOOK: fixup\n");
+ AP(current_hook) = AP_FIXUP;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php4_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->fixup_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_stacked_handler,
+ (int (*)(void *element, void *)) php_run_hook,
r);
}
@@ -1244,10 +1254,11 @@ static int php_logger_hook(request_rec *r)
{
php_per_dir_config *conf;
fprintf(stderr,"HOOK: logger\n");
+ AP(current_hook) = AP_LOGGING;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php4_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->logger_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_stacked_handler,
+ (int (*)(void *element, void *)) php_run_hook,
r);
}
@@ -1256,21 +1267,21 @@ static int php_post_read_hook(request_rec *r)
php_per_dir_config *conf;
php_per_server_config *svr;
fprintf(stderr,"HOOK: post-read\n");
-
+ AP(current_hook) = AP_POST_READ;
svr = get_module_config(r->server->module_config, &php4_module);
- sapi_stack_apply_with_argument_all(&svr->requires, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_stacked_handler, r);
+ sapi_stack_apply_with_argument_all(&svr->requires, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r);
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php4_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->post_read_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
- (int (*)(void *element, void *)) php_run_stacked_handler, r);
+ (int (*)(void *element, void *)) php_run_hook, r);
}
static int php_response_handler(request_rec *r)
{
php_per_dir_config *conf;
-
+ AP(current_hook) = AP_RESPONSE;
conf = get_module_config(r->per_dir_config, &php4_module);
- sapi_stack_apply_with_argument_all(&conf->response_handlers, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_stacked_handler, r);
+ sapi_stack_apply_with_argument_all(&conf->response_handlers, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r);
}
/* {{{ handler_rec php_handlers[]
diff --git a/sapi/apache/mod_php4.h b/sapi/apache/mod_php4.h
index 97cba24961..29e00796d7 100644
--- a/sapi/apache/mod_php4.h
+++ b/sapi/apache/mod_php4.h
@@ -32,14 +32,10 @@ typedef struct {
long xbithack;
long terminate_child;
long setup_env;
+ long current_hook;
zend_bool in_request;
zend_bool apache_config_loaded;
- char *uri_handler;
- char *auth_handler;
- char *access_handler;
- char *type_handler;
- char *fixup_handler;
- char *logger_handler;
+ zend_bool headers_sent;
} php_apache_info_struct;
extern zend_module_entry apache_module_entry;
@@ -52,6 +48,19 @@ extern php_apache_info_struct php_apache_info;
#define AP(v) (php_apache_info.v)
#endif
+/* defines for the various stages of the apache request */
+#define AP_WAITING_FOR_REQUEST 0
+#define AP_POST_READ 1
+#define AP_URI_TRANS 2
+#define AP_HEADER_PARSE 3
+#define AP_ACCESS_CONTROL 4
+#define AP_AUTHENTICATION 5
+#define AP_AUTHORIZATION 6
+#define AP_TYPE_CHECKING 7
+#define AP_FIXUP 8
+#define AP_RESPONSE 9
+#define AP_LOGGING 10
+#define AP_CLEANUP 11
#endif /* MOD_PHP4_H */
/*
diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c
index feadb8b5c0..bb62d770bf 100644
--- a/sapi/apache/php_apache.c
+++ b/sapi/apache/php_apache.c
@@ -45,7 +45,6 @@ static void apache_table_to_zval(table *, int safe_mode, zval *return_value);
PHP_FUNCTION(virtual);
PHP_FUNCTION(apache_request_headers);
PHP_FUNCTION(apache_response_headers);
-PHP_FUNCTION(apache_send_http_header);
PHP_FUNCTION(apachelog);
PHP_FUNCTION(apache_note);
PHP_FUNCTION(apache_lookup_uri);
@@ -58,7 +57,6 @@ PHP_MINFO_FUNCTION(apache);
function_entry apache_functions[] = {
PHP_FE(virtual, NULL)
PHP_FE(apache_request_headers, NULL)
- PHP_FE(apache_send_http_header, NULL)
PHP_FE(apache_note, NULL)
PHP_FE(apache_lookup_uri, NULL)
PHP_FE(apache_child_terminate, NULL)
@@ -75,13 +73,6 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("engine", "1", PHP_INI_ALL, OnUpdateInt, engine, php_apache_info_struct, php_apache_info)
STD_PHP_INI_ENTRY("last_modified", "0", PHP_INI_ALL, OnUpdateInt, last_modified, php_apache_info_struct, php_apache_info)
STD_PHP_INI_ENTRY("child_terminate", "0", PHP_INI_ALL, OnUpdateInt, terminate_child, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("uri_handler", NULL, PHP_INI_ALL, OnUpdateString, uri_handler, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("auth_handler", NULL, PHP_INI_ALL, OnUpdateString, auth_handler, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("access_handler", NULL, PHP_INI_ALL, OnUpdateString, access_handler, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("type_handler", NULL, PHP_INI_ALL, OnUpdateString, type_handler, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("fixup_handler", NULL, PHP_INI_ALL, OnUpdateString, fixup_handler, php_apache_info_struct, php_apache_info)
- STD_PHP_INI_ENTRY("logger_handler", NULL, PHP_INI_ALL, OnUpdateString, logger_handler, php_apache_info_struct, php_apache_info)
-
PHP_INI_END()
/* }}} */
@@ -106,7 +97,7 @@ static void php_apache_request_free(zend_rsrc_list_entry *rsrc TSRMLS_DC)
zval_ptr_dtor(&z);
}
-static request_rec *get_apache_request(zval *z)
+static request_rec *get_apache_request(pval *z)
{
request_rec *r;
zval **addr;
@@ -558,6 +549,8 @@ PHP_FUNCTION(apache_request_headers_in)
/* }}} */
+/* {{{ add_header_to_table
+*/
static void add_header_to_table(table *t, INTERNAL_FUNCTION_PARAMETERS)
{
zval *first = NULL;
@@ -959,6 +952,222 @@ PHP_FUNCTION(apache_request_basic_auth_pw)
/* }}} */
+/* http_protocol.h */
+
+PHP_FUNCTION(apache_request_send_http_header)
+{
+ zval *id;
+ request_rec *r;
+
+ APREQ_GET_REQUEST(id, r);
+ ap_send_http_header(r);
+ AP(headers_sent) = 1;
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_basic_http_header)
+{
+ zval *id;
+ request_rec *r;
+
+ APREQ_GET_REQUEST(id, r);
+
+ ap_basic_http_header((request_rec *)SG(server_context));
+ AP(headers_sent) = 1;
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_send_http_trace)
+{
+ zval *id;
+ request_rec *r;
+
+ APREQ_GET_REQUEST(id, r);
+
+ ap_send_http_trace((request_rec *)SG(server_context));
+ AP(headers_sent) = 1;
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_send_http_options)
+{
+ zval *id;
+ request_rec *r;
+
+ APREQ_GET_REQUEST(id, r);
+
+ ap_send_http_options((request_rec *)SG(server_context));
+ AP(headers_sent) = 1;
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_send_error_response)
+{
+ zval **recursive;
+ zval *id;
+ request_rec *r;
+ int rec;
+
+ TSRMLS_FETCH();
+
+ switch(ARG_COUNT(ht)) {
+ case 0:
+ rec = 0;
+ break;
+ case 1:
+ if(zend_get_parameters_ex(1, &recursive) == FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_long_ex(recursive);
+ rec = Z_LVAL_PP(recursive);
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ }
+ APREQ_GET_REQUEST(id, r);
+ ap_send_error_response(r, rec);
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_set_content_length)
+{
+ zval **length;
+ zval *id;
+ request_rec *r;
+
+ TSRMLS_FETCH();
+ if(ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &length) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ APREQ_GET_REQUEST(id, r);
+
+ convert_to_long_ex(length);
+ ap_set_content_length(r, Z_LVAL_PP(length));
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_set_keepalive)
+{
+ zval *id;
+ request_rec *r;
+ APREQ_GET_REQUEST(id, r);
+ ap_set_keepalive(r);
+ RETURN_TRUE;
+}
+
+/* This stuff should use streams or however this is implemented now
+
+PHP_FUNCTION(apache_request_send_fd)
+{
+}
+
+PHP_FUNCTION(apache_request_send_fd_length)
+{
+}
+*/
+
+/* These are for overriding default output behaviour */
+PHP_FUNCTION(apache_request_rputs)
+{
+ zval **buffer;
+ zval *id;
+ request_rec *r;
+ TSRMLS_FETCH();
+
+ if(ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &buffer) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ APREQ_GET_REQUEST(id, r);
+ convert_to_string_ex(buffer);
+ ap_rwrite(Z_STRVAL_PP(buffer), Z_STRLEN_PP(buffer), (request_rec*)SG(server_context));
+}
+
+/* This stuff would be useful for custom POST handlers,
+ which should be supported. Probably by not using
+ sapi_activate at all inside a phpResponseHandler
+ and instead using a builtin composed of the below
+ calls as a apache_read_request_body() and allow
+ people to custom craft their own.
+
+PHP_FUNCTION(apache_request_setup_client_block)
+{
+}
+
+PHP_FUNCTION(apache_request_should_client_block)
+{
+}
+
+PHP_FUNCTION(apache_request_get_client_block)
+{
+}
+
+PHP_FUNCTION(apache_request_discard_request_body)
+{
+}
+*/
+
+/* http_log.h */
+
+PHP_FUNCTION(apache_request_log_error)
+{
+
+}
+
+PHP_FUNCTION(apache_request_log_rerror)
+{
+}
+
+/* http_main.h */
+
+PHP_FUNCTION(apache_request_sub_req_lookup_uri)
+{
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_sub_req_lookup_file)
+{
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_sub_req_method_uri)
+{
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_run_sub_req)
+{
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_destroy_sub_req)
+{
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_internal_redirect)
+{
+ RETURN_TRUE;
+}
+
+PHP_FUNCTION(apache_request_send_header_field)
+{
+ zval **fieldname;
+ zval **fieldval;
+ zval *id;
+ request_rec *r;
+
+ TSRMLS_FETCH();
+ if(ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &fieldname, &fieldval) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_string_ex(fieldname);
+ convert_to_string_ex(fieldval);
+ APREQ_GET_REQUEST(id, r);
+
+ ap_send_header_field(r, Z_STRVAL_PP(fieldname), Z_STRVAL_PP(fieldval));
+ AP(headers_sent) = 1;
+}
+
/* }}} */
@@ -1016,6 +1225,16 @@ static function_entry php_apache_request_class_functions[] = {
#undef set_last_modified
#undef some_auth_required
#undef update_mtime
+#undef send_http_header
+#undef basic_http_header
+#undef send_http_trace
+#undef send_http_options
+#undef send_error_response
+#undef set_content_length
+#undef set_keepalive
+#undef rputs
+#undef log_error
+#undef log_rerror
PHP_FALIAS(auth_name, apache_request_auth_name, NULL)
PHP_FALIAS(auth_type, apache_request_auth_type, NULL)
PHP_FALIAS(basic_auth_pw, apache_request_basic_auth_pw, NULL)
@@ -1029,7 +1248,23 @@ static function_entry php_apache_request_class_functions[] = {
PHP_FALIAS(set_last_modified, apache_request_set_last_modified, NULL)
PHP_FALIAS(some_auth_required, apache_request_some_auth_required, NULL)
PHP_FALIAS(update_mtime, apache_request_update_mtime, NULL)
-
+ PHP_FALIAS(send_http_header, apache_request_send_http_header, NULL)
+ PHP_FALIAS(basic_http_header, apache_request_basic_http_header, NULL)
+ PHP_FALIAS(send_header_field, apache_request_send_header_field, NULL)
+ PHP_FALIAS(send_http_trace, apache_request_send_http_trace, NULL)
+ PHP_FALIAS(send_http_options, apache_request_send_http_trace, NULL)
+ PHP_FALIAS(send_error_response, apache_request_send_error_response, NULL)
+ PHP_FALIAS(set_content_length, apache_request_set_content_length, NULL)
+ PHP_FALIAS(set_keepalive, apache_request_set_keepalive, NULL)
+ PHP_FALIAS(rputs, apache_request_rputs, NULL)
+ PHP_FALIAS(log_error, apache_request_log_error, NULL)
+ PHP_FALIAS(log_rerror, apache_request_log_rerror, NULL)
+ PHP_FALIAS(sub_req_lookup_uri, apache_request_sub_req_lookup_uri, NULL)
+ PHP_FALIAS(sub_req_lookup_file, apache_request_sub_req_lookup_file, NULL)
+ PHP_FALIAS(sub_req_method_uri, apache_request_sub_req_method_uri, NULL)
+ PHP_FALIAS(run_sub_req, apache_request_run_sub_req, NULL)
+ PHP_FALIAS(destroy_sub_req, apache_request_destroy_sub_req, NULL)
+ PHP_FALIAS(internal_redirect, apache_request_internal_redirect, NULL)
{ NULL, NULL, NULL }
};
/* }}} */
@@ -1141,7 +1376,7 @@ PHP_FUNCTION(apache_child_terminate)
Get and set Apache request notes */
PHP_FUNCTION(apache_note)
{
- pval **arg_name, **arg_val;
+ zval **arg_name, **arg_val;
char *note_val;
int arg_count = ARG_COUNT(ht);
@@ -1370,8 +1605,10 @@ static void apache_table_to_zval(table *t, int safe_mode, zval *return_value)
/* {{{ proto array getallheaders(void)
- Alias for apache_request_headers() */
+*/
+/* Alias for apache_request_headers() */
/* }}} */
+
/* {{{ proto array apache_request_headers(void)
Fetch all HTTP request headers */
PHP_FUNCTION(apache_request_headers)
@@ -1388,10 +1625,6 @@ PHP_FUNCTION(apache_response_headers)
}
/* }}} */
-PHP_FUNCTION(apache_send_http_header)
-{
- ap_send_http_header((request_rec *)SG(server_context));
-}
/* {{{ proto bool apache_setenv(string variable, string value [, bool walk_to_top])
Set an Apache subprocess_env variable */
PHP_FUNCTION(apache_setenv)
diff --git a/sapi/apache/sapi_apache.c b/sapi/apache/sapi_apache.c
index 248268da45..2e6c61d45d 100644
--- a/sapi/apache/sapi_apache.c
+++ b/sapi/apache/sapi_apache.c
@@ -69,10 +69,15 @@ int apache_php_module_hook(request_rec *r, char *filename, zval **ret TSRMLS_DC)
#if PHP_SIGCHILD
signal(SIGCHLD, sigchld_handler);
#endif
-
- if (php_request_startup_for_hook(TSRMLS_C) == FAILURE)
+ if(AP(current_hook) == AP_RESPONSE) {
+ fprintf(stderr, "in Response\n");
+ if (php_request_startup_for_hook(TSRMLS_C) == FAILURE)
return FAILURE;
-
+ }
+ else {
+ if (php_request_startup_for_hook(TSRMLS_C) == FAILURE)
+ return FAILURE;
+ }
/* Add PHP_SELF_HOOK - Absolute path */
php_register_variable("PHP_SELF_HOOK", filename, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);