summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-05-05 19:53:15 +0000
committerZeev Suraski <zeev@php.net>1999-05-05 19:53:15 +0000
commit2740382c2c5758e72850e8357046b94b9ac3e5e4 (patch)
treeedd8d15fb3ad96e6d0c81529a1e7e5d24d2ca929
parentc8b2bf0a1d57e5c244ddd477255a2a5c662b8e58 (diff)
downloadphp-git-2740382c2c5758e72850e8357046b94b9ac3e5e4.tar.gz
ISAPI WORKS!
-rw-r--r--main/SAPI.c22
-rw-r--r--main/SAPI.h1
-rw-r--r--main/main.c4
-rw-r--r--output.c16
4 files changed, 38 insertions, 5 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index c107365366..12499aee3b 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -41,6 +41,7 @@ SAPI_API void sapi_activate(SLS_D)
zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0);
SG(sapi_headers).content_type.header = NULL;
SG(sapi_headers).http_response_code = 200;
+ SG(headers_sent) = 0;
}
@@ -62,7 +63,11 @@ SAPI_API int sapi_add_header(const char *header_line, uint header_line_len)
sapi_header.header = (char *) header_line;
sapi_header.header_len = header_line_len;
- retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers));
+ if (sapi_module.header_handler) {
+ retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers));
+ } else {
+ retval = SAPI_HEADER_ADD;
+ }
if (retval & SAPI_HEADER_DELETE_ALL) {
zend_llist_clean(&SG(sapi_headers).headers);
@@ -91,14 +96,27 @@ SAPI_API int sapi_add_header(const char *header_line, uint header_line_len)
SAPI_API int sapi_send_headers()
{
+ int retval;
SLS_FETCH();
- switch (sapi_module.send_headers(&SG(sapi_headers) SLS_CC)) {
+ if (SG(headers_sent)) {
+ return SUCCESS;
+ }
+
+ if (sapi_module.send_headers) {
+ retval = sapi_module.send_headers(&SG(sapi_headers) SLS_CC);
+ } else {
+ retval = SAPI_HEADER_DO_SEND;
+ }
+
+ switch (retval) {
case SAPI_HEADER_SENT_SUCCESSFULLY:
+ SG(headers_sent) = 1;
return SUCCESS;
break;
case SAPI_HEADER_DO_SEND:
zend_llist_apply_with_argument(&SG(sapi_headers).headers, (void (*)(void *, void *)) sapi_module.send_header, SG(server_context));
+ SG(headers_sent) = 1;
return SUCCESS;
break;
case SAPI_HEADER_SEND_FAILED:
diff --git a/main/SAPI.h b/main/SAPI.h
index 2b76ceae4c..58ef0c081a 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -49,6 +49,7 @@ typedef struct {
void *server_context;
sapi_request_info request_info;
sapi_headers_struct sapi_headers;
+ unsigned char headers_sent;
} sapi_globals_struct;
diff --git a/main/main.c b/main/main.c
index cfc39a5a0d..d1ccc629e4 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1126,14 +1126,14 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
if (!strcmp(SG(request_info).query_string+1, "PHPE9568F34-D428-11d2-A769-00AA001ACF42")) {
char *header_line = estrndup(CONTEXT_TYPE_IMAGE_GIF, sizeof(CONTEXT_TYPE_IMAGE_GIF));
- php4i_add_header_information(header_line, sizeof(CONTEXT_TYPE_IMAGE_GIF));
+ php4i_add_header_information(header_line, sizeof(CONTEXT_TYPE_IMAGE_GIF)-1);
PHPWRITE(php4_logo, sizeof(php4_logo));
efree(header_line);
return;
} else if (!strcmp(SG(request_info).query_string+1, "PHPE9568F35-D428-11d2-A769-00AA001ACF42")) {
char *header_line = estrndup(CONTEXT_TYPE_IMAGE_GIF, sizeof(CONTEXT_TYPE_IMAGE_GIF));
- php4i_add_header_information(header_line, sizeof(CONTEXT_TYPE_IMAGE_GIF));
+ php4i_add_header_information(header_line, sizeof(CONTEXT_TYPE_IMAGE_GIF)-1);
PHPWRITE(zendtech_logo, sizeof(zendtech_logo));
efree(header_line);
return;
diff --git a/output.c b/output.c
index c18650f2f4..327ed06fb8 100644
--- a/output.c
+++ b/output.c
@@ -22,6 +22,7 @@
int (*zend_body_write)(const char *str, uint str_length); /* string output */
int (*zend_header_write)(const char *str, uint str_length); /* unbuffer string output */
static int zend_ub_body_write(const char *str, uint str_length);
+static int zend_ub_body_write_no_header(const char *str, uint str_length);
static int zend_b_body_write(const char *str, uint str_length);
/* output buffering */
@@ -57,10 +58,16 @@ void zend_start_ob_buffering()
void zend_end_ob_buffering(int send_buffer)
{
+ SLS_FETCH();
+
if (!ob_buffer) {
return;
}
- zend_body_write = zend_ub_body_write;
+ if (SG(headers_sent)) {
+ zend_body_write = zend_ub_body_write_no_header;
+ } else {
+ zend_body_write = zend_ub_body_write;
+ }
if (send_buffer) {
zend_ob_send();
}
@@ -166,6 +173,12 @@ static int zend_b_body_write(const char *str, uint str_length)
}
+static int zend_ub_body_write_no_header(const char *str, uint str_length)
+{
+ return zend_header_write(str, str_length);
+}
+
+
static int zend_ub_body_write(const char *str, uint str_length)
{
SLS_FETCH();
@@ -174,6 +187,7 @@ static int zend_ub_body_write(const char *str, uint str_length)
zend_bailout();
}
if (php3_header()) {
+ zend_body_write = zend_ub_body_write_no_header;
return zend_header_write(str, str_length);
} else {
return 0;