X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_api.h;h=472c4b902b7e8559f9f1c691757aa030f4ac8aa9;hp=b6572225abb03c1a9bd27d24dbb14468ddfff3d7;hb=e47ee304be6758fbbfd238476f8a6bda9090fe12;hpb=2b7331c5fdb73cb48f7f60a8e4ec88766581ced3 diff --git a/php_http_api.h b/php_http_api.h index b657222..472c4b9 100644 --- a/php_http_api.h +++ b/php_http_api.h @@ -23,9 +23,25 @@ #define pretty_key(key, key_len, uctitle, xhyphen) _http_pretty_key(key, key_len, uctitle, xhyphen) extern char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen); +typedef void (*http_key_list_decode_t)(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC); +#define http_key_list_default_decoder _http_key_list_default_decoder +extern void _http_key_list_default_decoder(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC); + +#define http_parse_cookie(l, i) _http_parse_key_list((l), (i), ';', http_key_list_default_decoder, 1 TSRMLS_CC) +#define http_parse_key_list(l, i, s, d, f) _http_parse_key_list((l), (i), (s), (d), (f) TSRMLS_CC) +extern STATUS _http_parse_key_list(const char *list, HashTable *items, char separator, http_key_list_decode_t decode, zend_bool first_entry_is_name_value_pair TSRMLS_DC); + #define http_error(type, code, string) _http_error_ex(type, code, "%s", string) #define http_error_ex _http_error_ex -extern void _http_error_ex(long type, long code, const char *format, ...); +extern void _http_error_ex(long type, long code, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); + +#define http_exit(s, h) http_exit_ex((s), (h), 1) +#define http_exit_ex(s, h, f) _http_exit_ex((s), (h), (f) TSRMLS_CC) +extern STATUS _http_exit_ex(int status, char *header, zend_bool free_header TSRMLS_DC); + +#define http_check_method(m) http_check_method_ex((m), HTTP_KNOWN_METHODS) +#define http_check_method_ex(m, a) _http_check_method_ex((m), (a)) +extern STATUS _http_check_method_ex(const char *method, const char *methods); #define HTTP_GSC(var, name, ret) HTTP_GSP(var, name, return ret) #define HTTP_GSP(var, name, ret) \ @@ -37,16 +53,15 @@ extern void _http_error_ex(long type, long code, const char *format, ...); #define http_get_server_var_ex(v, s) _http_get_server_var_ex((v), (s), 0 TSRMLS_CC) PHP_HTTP_API zval *_http_get_server_var_ex(const char *key, size_t key_size, zend_bool check TSRMLS_DC); -#define http_ob_etaghandler(o, l, ho, hl, m) _http_ob_etaghandler((o), (l), (ho), (hl), (m) TSRMLS_CC) -PHP_HTTP_API void _http_ob_etaghandler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC); +#define http_get_request_body(b, l) _http_get_request_body_ex((b), (l), 1 TSRMLS_CC) +#define http_get_Request_body_ex(b, l, d) _http_get_request_body_ex((b), (l), (d) TSRMLS_CC) +PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_bool dup TSRMLS_DC); #define http_chunked_decode(e, el, d, dl) _http_chunked_decode((e), (el), (d), (dl) TSRMLS_CC) -PHP_HTTP_API STATUS _http_chunked_decode(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC); +PHP_HTTP_API const char *_http_chunked_decode(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC); -#define http_split_response(r, h, b) _http_split_response((r), (h), (b) TSRMLS_CC) -PHP_HTTP_API STATUS _http_split_response(zval *response, zval *headers, zval *body TSRMLS_DC); -#define http_split_response_ex(r, rl, h, b, bl) _http_split_response_ex((r), (rl), (h), (b), (bl) TSRMLS_CC) -PHP_HTTP_API STATUS _http_split_response_ex(char *response, size_t repsonse_len, HashTable *headers, char **body, size_t *body_len TSRMLS_DC); +#define http_split_response(r, rl, h, b, bl) _http_split_response((r), (rl), (h), (b), (bl) TSRMLS_CC) +PHP_HTTP_API STATUS _http_split_response(char *response, size_t repsonse_len, HashTable *headers, char **body, size_t *body_len TSRMLS_DC); #endif