summaryrefslogtreecommitdiff
path: root/sapi/nsapi/nsapi.c
diff options
context:
space:
mode:
authorUwe Schindler <thetaphi@php.net>2003-06-01 21:14:58 +0000
committerUwe Schindler <thetaphi@php.net>2003-06-01 21:14:58 +0000
commit827734280b64e3424f97df9c5e37b7e97791592b (patch)
tree315ca6d67b5d8c4e7cc9c420d60f1850036def94 /sapi/nsapi/nsapi.c
parentef4ffaaf1ad2dd59b55e4493f979221f0d2ff94e (diff)
downloadphp-git-827734280b64e3424f97df9c5e37b7e97791592b.tar.gz
Update of README for newer servers; apache-similar functions nsapi_request_headers and nsapi_response_headers with apache_* aliases; hide authorization-header in save mode.
Diffstat (limited to 'sapi/nsapi/nsapi.c')
-rw-r--r--sapi/nsapi/nsapi.c79
1 files changed, 68 insertions, 11 deletions
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c
index c42b07ae76..b34c042c1d 100644
--- a/sapi/nsapi/nsapi.c
+++ b/sapi/nsapi/nsapi.c
@@ -161,6 +161,8 @@ PHP_RSHUTDOWN_FUNCTION(nsapi);
PHP_MINFO_FUNCTION(nsapi);
PHP_FUNCTION(virtual);
+PHP_FUNCTION(nsapi_request_headers);
+PHP_FUNCTION(nsapi_response_headers);
ZEND_BEGIN_MODULE_GLOBALS(nsapi)
long read_timeout;
@@ -180,8 +182,13 @@ ZEND_DECLARE_MODULE_GLOBALS(nsapi)
* Every user visible function must have an entry in nsapi_functions[].
*/
function_entry nsapi_functions[] = {
- PHP_FE(virtual, NULL) /* Make subrequest */
- {NULL, NULL, NULL} /* Must be the last line in nsapi_functions[] */
+ PHP_FE(virtual, NULL) /* Make subrequest */
+ PHP_FE(nsapi_request_headers, NULL) /* get request headers */
+ PHP_FALIAS(getallheaders, nsapi_request_headers, NULL) /* compatibility */
+ PHP_FALIAS(apache_request_headers, nsapi_request_headers, NULL) /* compatibility */
+ PHP_FE(nsapi_response_headers, NULL) /* get response headers */
+ PHP_FALIAS(apache_response_headers, nsapi_response_headers, NULL) /* compatibility */
+ {NULL, NULL, NULL}
};
/* }}} */
@@ -196,7 +203,7 @@ zend_module_entry nsapi_module_entry = {
NULL,
NULL,
PHP_MINFO(nsapi),
- NO_VERSION_YET,
+ "$Id$",
STANDARD_MODULE_PROPERTIES
};
/* }}} */
@@ -297,7 +304,7 @@ PHP_MSHUTDOWN_FUNCTION(nsapi)
PHP_MINFO_FUNCTION(nsapi)
{
php_info_print_table_start();
- php_info_print_table_row(2, "NSAPI support", "enabled");
+ php_info_print_table_row(2, "NSAPI Module Version", nsapi_module_entry.version);
php_info_print_table_row(2, "Server Software", system_version());
php_info_print_table_row(2, "Sub-requests with virtual()",
(nsapi_servact_service)?((zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0))?"not supported with zlib.output_compression":"enabled"):"not supported on this platform" );
@@ -384,6 +391,54 @@ PHP_FUNCTION(virtual)
}
/* }}} */
+/* {{{ proto array nsapi_request_headers(void)
+ Get all headers from the request */
+PHP_FUNCTION(nsapi_request_headers)
+{
+ register int i;
+ struct pb_entry *entry;
+ nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
+
+ if (array_init(return_value) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ for (i=0; i < rc->rq->headers->hsize; i++) {
+ entry=rc->rq->headers->ht[i];
+ while (entry) {
+ if (!PG(safe_mode) || strcasecmp(entry->param->name, "authorization")) {
+ add_assoc_string(return_value, entry->param->name, entry->param->value, 1);
+ }
+ entry=entry->next;
+ }
+ }
+}
+/* }}} */
+
+/* {{{ proto array nsapi_response_headers(void)
+ Get all headers from the response */
+PHP_FUNCTION(nsapi_response_headers)
+{
+ register int i;
+ struct pb_entry *entry;
+ nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
+
+ if (array_init(return_value) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_header();
+
+ for (i=0; i < rc->rq->srvhdrs->hsize; i++) {
+ entry=rc->rq->srvhdrs->ht[i];
+ while (entry) {
+ add_assoc_string(return_value, entry->param->name, entry->param->value, 1);
+ entry=entry->next;
+ }
+ }
+}
+/* }}} */
+
/*************/
/* SAPI part */
@@ -551,15 +606,17 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D
for (i=0; i < rc->rq->headers->hsize; i++) {
entry=rc->rq->headers->ht[i];
while (entry) {
- snprintf(buf, NS_BUF_SIZE, "HTTP_%s", entry->param->name);
- for(p = buf + 5; *p; p++) {
- *p = toupper(*p);
- if (*p < 'A' || *p > 'Z') {
- *p = '_';
+ if (!PG(safe_mode) || strcasecmp(entry->param->name, "authorization")) {
+ snprintf(buf, NS_BUF_SIZE, "HTTP_%s", entry->param->name);
+ for(p = buf + 5; *p; p++) {
+ *p = toupper(*p);
+ if (*p < 'A' || *p > 'Z') {
+ *p = '_';
+ }
}
+ buf[NS_BUF_SIZE]='\0';
+ php_register_variable(buf, entry->param->value, track_vars_array TSRMLS_CC);
}
- buf[NS_BUF_SIZE]='\0';
- php_register_variable(buf, entry->param->value, track_vars_array TSRMLS_CC);
entry=entry->next;
}
}