Skip to content

Commit

Permalink
Merge pull request #3 from zelgerj/master
Browse files Browse the repository at this point in the history
added delete after return flag to appserver_get_headers
  • Loading branch information
zelgerj committed Nov 24, 2013
2 parents db0e469 + 0c9e202 commit f5924f0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
4 changes: 2 additions & 2 deletions build.default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# ---- General Settings ---------------------------------------------------------
php.ext.name = appserver

release.version = 0.1.2
release.version = 0.1.3
release.stability = beta
api.version = 0.1.2
api.version = 0.1.3
api.stability = beta

php.version = 5.5.2
Expand Down
8 changes: 8 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
<include name="**/*" />
</fileset>
</copy>
<copy todir="${c-target.dir}/${php.ext.name}" preservelastmodified="true" overwrite="true">
<fileset dir="${c-src.dir}">
<include name="php_appserver.h" />
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<copy todir="${c-target.dir}/${php.ext.name}" preservelastmodified="true" overwrite="true">
<fileset dir="${c-pecl.dir}">
<include name="**/*"/>
Expand Down
18 changes: 15 additions & 3 deletions src/appserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const zend_function_entry appserver_functions[] = {

zend_module_entry appserver_module_entry = {
STANDARD_MODULE_HEADER,
"appserver",
APPSERVER_NAME,
appserver_functions,
PHP_MINIT(appserver),
PHP_MSHUTDOWN(appserver),
Expand Down Expand Up @@ -217,8 +217,9 @@ PHP_RSHUTDOWN_FUNCTION(appserver)

PHP_MINFO_FUNCTION(appserver)
{
php_info_print_table_start();
php_info_print_table_start();
php_info_print_table_header(2, "appserver support", "enabled");
php_info_print_table_row(2, "Version", APPSERVER_VERSION);
php_info_print_table_end();

/* Remove comments if you have entries in php.ini
Expand Down Expand Up @@ -308,16 +309,27 @@ PHP_FUNCTION(appserver_register_file_upload)
RETURN_TRUE;
}

/* {{{ proto array appserver_get_headers(boolean $reset_headers_flag)
gets headers set via header function and reset if flag was set ... /* }}} */
PHP_FUNCTION(appserver_get_headers)
{
appserver_llist_item *header_item;
zend_bool headers_reset_flag = 0;
char *string;

// parse params
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &headers_reset_flag) == FAILURE) {
return;
}
// init return value as array
array_init(return_value);
for (header_item = APPSERVER_GLOBALS(headers)->head; header_item != NULL; header_item = header_item->next) {
string = header_item->ptr;
add_next_index_string(return_value, string, 1);
}
// clear headers globals hash if delete flag was given
if (headers_reset_flag != 0) {
appserver_llist_clear(APPSERVER_GLOBALS(headers));
}
}

PHP_FUNCTION(appserver_set_headers_sent)
Expand Down
13 changes: 10 additions & 3 deletions src/appserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,24 @@
appserver_set_headers_sent(true);
$result = var_export(headers_sent(), true);
echo "CALL appserver_set_headers_sent(true): -> headers_sent = " . $result . PHP_EOL;
appserver_set_headers_sent(false);
appserver_set_headers_sent();
$result = var_export(headers_sent(), true);
echo "CALL appserver_set_headers_sent(false): -> headers_sent = " . $result;
echo PHP_EOL . "==========================================". PHP_EOL;

appserver_set_headers_sent(false);
header('X-Powered-By: appserver');
header('Location: http://www.google.de');
echo "CALL appserver_get_headers(): -> ";
header('Location: http://www.appserver.io');
echo "CALL #1 appserver_get_headers(): -> ";
echo var_export(appserver_get_headers(), true);
echo PHP_EOL . "==========================================". PHP_EOL;
echo "CALL #2 appserver_get_headers(true): -> ";
echo var_export(appserver_get_headers(true), true);
echo PHP_EOL . "==========================================". PHP_EOL;
echo "CALL #3 appserver_get_headers(): -> ";
echo var_export(appserver_get_headers(), true);
echo PHP_EOL . "==========================================". PHP_EOL;


echo "CALL headers_sent(): -> ";
echo var_export(headers_sent(), true);
Expand Down
5 changes: 3 additions & 2 deletions src/php_appserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
extern zend_module_entry appserver_module_entry;
#define phpext_appserver_ptr &appserver_module_entry

#define APPSERVER_VERSION "0.1.0"
#define APPSERVER_NAME "${php.ext.name}"
#define APPSERVER_VERSION "${release.version}"

#ifdef PHP_WIN32
# define PHP_APPSERVER_API __declspec(dllexport)
Expand Down Expand Up @@ -71,7 +72,7 @@ PHP_FUNCTION(appserver_redefine);

ZEND_BEGIN_MODULE_GLOBALS(appserver)
appserver_llist *headers;
HashTable *uploaded_files;
HashTable *uploaded_files;
HashTable redefined;
long pproftrace;
ZEND_END_MODULE_GLOBALS(appserver)
Expand Down

0 comments on commit f5924f0

Please sign in to comment.