Added initial headers support in SAPI

*untested*
It definitely broke the thread-safe CGI, it may have broken other stuff as well.
This commit is contained in:
Andi Gutmans 1999-05-05 18:25:20 +00:00
parent 9e67cded5e
commit 537cc54acd
7 changed files with 175 additions and 20 deletions

View file

@ -1,6 +1,9 @@
#ifndef _NEW_SAPI_H
#define _NEW_SAPI_H
#include "zend.h"
#include "zend_llist.h"
#if WIN32||WINNT
# ifdef SAPI_EXPORTS
@ -13,14 +16,20 @@
#endif
typedef struct _sapi_module_struct {
char *name;
typedef struct {
char *header;
uint header_len;
} sapi_header_struct;
int (*startup)(struct _sapi_module_struct *sapi_module);
int (*shutdown)(struct _sapi_module_struct *sapi_module);
int (*ub_write)(const char *str, unsigned int str_length);
} sapi_module_struct;
typedef struct {
zend_llist headers;
sapi_header_struct content_type;
int http_response_code;
} sapi_headers_struct;
typedef struct _sapi_module_struct sapi_module_struct;
extern sapi_module_struct sapi_module; /* true global */
@ -31,16 +40,24 @@ typedef struct {
char *path_translated;
char *request_uri;
unsigned char headers_only;
} sapi_request_info;
typedef struct {
void *server_context;
sapi_request_info request_info;
sapi_headers_struct sapi_headers;
} sapi_globals_struct;
SAPI_API void sapi_startup(sapi_module_struct *sf);
SAPI_API void sapi_activate(SLS_D);
SAPI_API void sapi_deactivate(SLS_D);
SAPI_API int sapi_add_header(const char *header_line, uint header_line_len);
SAPI_API int sapi_send_headers();
#ifdef ZTS
# define SLS_D sapi_globals_struct *sapi_globals
@ -61,4 +78,32 @@ extern SAPI_API sapi_globals_struct sapi_globals;
#endif
struct _sapi_module_struct {
char *name;
int (*startup)(struct _sapi_module_struct *sapi_module);
int (*shutdown)(struct _sapi_module_struct *sapi_module);
int (*ub_write)(const char *str, unsigned int str_length);
int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers);
int (*send_headers)(sapi_headers_struct *sapi_headers SLS_DC);
void (*send_header)(void *server_context, sapi_header_struct *sapi_header);
};
/* header_handler() constants */
#define SAPI_HEADER_ADD (1<<0)
#define SAPI_HEADER_DELETE_ALL (1<<1)
#define SAPI_HEADER_SEND_NOW (1<<2)
#define SAPI_HEADER_SENT_SUCCESSFULLY 1
#define SAPI_HEADER_DO_SEND 2
#define SAPI_HEADER_SEND_FAILED 3
#define DEFAULT_CONTENT_TYPE "Content-Type: text/html"
#endif /* _NEW_SAPI_H */