summaryrefslogtreecommitdiff
path: root/main/SAPI.h
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2002-07-03 10:42:31 +0000
committerSascha Schumann <sas@php.net>2002-07-03 10:42:31 +0000
commit9c876ea01ad806ae6e345c5dc0cf252c0ebe8864 (patch)
tree60c5f992ca4a366896c4166747336f79ca7e9164 /main/SAPI.h
parentc73733c59acef49b86af5996cb0ec12b970a7759 (diff)
downloadphp-git-9c876ea01ad806ae6e345c5dc0cf252c0ebe8864.tar.gz
Add sapi_header_op interface which supersedes the sapi_add_header and _ex
calls. Revert the change to the sapi_add_header_ex interface. Fix various bugs: 1. header("HTTP/1.0 306 foo"); header("Location: absolute-uri"); did not work in combination with several SAPI modules, because http_status_line was never properly reset. And thus, all SAPI modules which looked at http_status_line ignored the changed http_response_code. 2. The CGI SAPI did not send out the HTTP status line at all, if http_status_line had not been set explicitly by calling header("HTTP/1.0 200 foo");
Diffstat (limited to 'main/SAPI.h')
-rw-r--r--main/SAPI.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/main/SAPI.h b/main/SAPI.h
index c335b32795..dd2753d9cd 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -133,9 +133,37 @@ SAPI_API void sapi_activate(TSRMLS_D);
SAPI_API void sapi_deactivate(TSRMLS_D);
SAPI_API void sapi_initialize_empty_request(TSRMLS_D);
-SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace, int http_response_code TSRMLS_DC);
-#define sapi_add_header(header_line, header_line_len, duplicate) \
- sapi_add_header_ex((header_line), (header_line_len), (duplicate), 1, 0 TSRMLS_CC)
+/*
+ * This is the preferred and maintained API for
+ * operating on HTTP headers.
+ */
+
+/*
+ * Always specify a sapi_header_line this way:
+ *
+ * sapi_header_line ctr = {0};
+ */
+
+typedef struct {
+ char *line; /* If you allocated this, you need to free it yourself */
+ uint line_len;
+ long response_code; /* long due to zend_parse_parameters compatibility */
+} sapi_header_line;
+
+typedef enum { /* Parameter: */
+ SAPI_HEADER_REPLACE, /* sapi_header_line* */
+ SAPI_HEADER_ADD, /* sapi_header_line* */
+ SAPI_HEADER_SET_STATUS /* int */
+} sapi_header_op_enum;
+
+SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC);
+
+
+/* Deprecated functions. Use sapi_header_op instead. */
+SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC);
+#define sapi_add_header(a, b, c) sapi_add_header_ex((a),(b),(c),1 TSRMLS_CC)
+
+
SAPI_API int sapi_send_headers(TSRMLS_D);
SAPI_API void sapi_free_header(sapi_header_struct *sapi_header);
SAPI_API void sapi_handle_post(void *arg TSRMLS_DC);