ISAPI WORKS!

This commit is contained in:
Zeev Suraski 1999-05-05 19:53:15 +00:00
parent c8b2bf0a1d
commit 2740382c2c
4 changed files with 38 additions and 5 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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;

View File

@ -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;