X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_send_api.h;h=8845afd9b5843e2067b748259cadb1cbc74ef863;hp=52129150e0ded6a05296bebff41458dbeaaa2572;hb=61ced187b8a3a3c21578d253e37d1a076aa0aed4;hpb=0ac32c9b8590e88a5f110cc8b3154001d5c0c089 diff --git a/php_http_send_api.h b/php_http_send_api.h index 5212915..8845afd 100644 --- a/php_http_send_api.h +++ b/php_http_send_api.h @@ -28,18 +28,24 @@ typedef enum { } http_send_mode; #define http_send_status(s) sapi_header_op(SAPI_HEADER_SET_STATUS, (void *) (s) TSRMLS_CC) -#define http_send_header(h) http_send_status_header(0, (h)) -#define http_send_status_header(s, h) _http_send_status_header((s), (h) TSRMLS_CC) -PHP_HTTP_API STATUS _http_send_status_header(int status, const char *header TSRMLS_DC); +#define http_send_header(n, v, r) _http_send_header_ex((n), strlen(n), (v), strlen(v), (r) TSRMLS_CC) +#define http_send_header_ex(n, nl, v, vl, r, s) _http_send_header_ex((n), (nl), (v), (vl), (r), (s) TSRMLS_CC) +PHP_HTTP_API STATUS _http_send_header_ex(const char *name, size_t name_len, const char *value, size_t value_len, zend_bool replace, char **sent_header TSRMLS_DC); +#define http_send_header_string(h) _http_send_status_header_ex(0, (h), 1 TSRMLS_CC) +#define http_send_header_string_ex(h, r) _http_send_status_header_ex(0, (h), (r) TSRMLS_CC) +#define http_send_status_header(s, h) _http_send_status_header_ex((s), (h), 1 TSRMLS_CC) +#define http_send_status_header_ex(s, h, r) _http_send_status_header_ex((s), (h), (r) TSRMLS_CC) +PHP_HTTP_API STATUS _http_send_status_header_ex(int status, const char *header, zend_bool replace TSRMLS_DC); -#define http_send_last_modified(t) _http_send_last_modified((t) TSRMLS_CC) -PHP_HTTP_API STATUS _http_send_last_modified(time_t t TSRMLS_DC); +#define http_send_last_modified(t) _http_send_last_modified_ex((t), NULL TSRMLS_CC) +#define http_send_last_modified_ex(t, s) _http_send_last_modified_ex((t), (s) TSRMLS_CC) +PHP_HTTP_API STATUS _http_send_last_modified_ex(time_t t, char **sent_header TSRMLS_DC); -#define http_send_etag(e, l) _http_send_etag((e), (l) TSRMLS_CC) -PHP_HTTP_API STATUS _http_send_etag(const char *etag, size_t etag_len TSRMLS_DC); +#define http_send_etag(e, l) _http_send_etag_ex((e), (l), NULL TSRMLS_CC) +#define http_send_etag_ex(e, l, s) _http_send_etag_ex((e), (l), (s) TSRMLS_CC) +PHP_HTTP_API STATUS _http_send_etag_ex(const char *etag, size_t etag_len, char **sent_header TSRMLS_DC); -#define http_send_cache_control(c, l) _http_send_cache_control((c), (l) TSRMLS_CC) -PHP_HTTP_API STATUS _http_send_cache_control(const char *cache_control, size_t cc_len TSRMLS_DC); +#define http_send_cache_control(cc, cl) http_send_header_ex("Cache-Control", lenof("Cache-Control"), (cc), (cl), 1, NULL) #define http_send_content_type(c, l) _http_send_content_type((c), (l) TSRMLS_CC) PHP_HTTP_API STATUS _http_send_content_type(const char *content_type, size_t ct_len TSRMLS_DC); @@ -51,13 +57,16 @@ PHP_HTTP_API STATUS _http_send_content_disposition(const char *filename, size_t PHP_HTTP_API STATUS _http_send_ranges(HashTable *ranges, const void *data, size_t size, http_send_mode mode TSRMLS_DC); #define http_send_data(d, l) http_send((d), (l), SEND_DATA) -#define http_send(d, s, m) _http_send((d), (s), (m) TSRMLS_CC) -PHP_HTTP_API STATUS _http_send(const void *data, size_t data_size, http_send_mode mode TSRMLS_DC); - -#define http_send_file(f) http_send_stream_ex(php_stream_open_wrapper(f, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL), 1) -#define http_send_stream(s) http_send_stream_ex((s), 0) -#define http_send_stream_ex(s, c) _http_send_stream_ex((s), (c) TSRMLS_CC) -PHP_HTTP_API STATUS _http_send_stream_ex(php_stream *s, zend_bool close_stream TSRMLS_DC); +#define http_send_data_ex(d, l, nc) http_send_ex((d), (l), SEND_DATA, (nc)) +#define http_send(d, s, m) _http_send_ex((d), (s), (m), 0 TSRMLS_CC) +#define http_send_ex(d, s, m, nc) _http_send_ex((d), (s), (m), (nc) TSRMLS_CC) +PHP_HTTP_API STATUS _http_send_ex(const void *data, size_t data_size, http_send_mode mode, zend_bool no_cache TSRMLS_DC); + +#define http_send_file(f) http_send_stream_ex(php_stream_open_wrapper(f, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL), 1, 0) +#define http_send_file_ex(f, nc) http_send_stream_ex(php_stream_open_wrapper(f, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL), 1, (nc)) +#define http_send_stream(s) http_send_stream_ex((s), 0, 0) +#define http_send_stream_ex(s, c, nc) _http_send_stream_ex((s), (c), (nc) TSRMLS_CC) +PHP_HTTP_API STATUS _http_send_stream_ex(php_stream *s, zend_bool close_stream, zend_bool no_cache TSRMLS_DC); #endif