X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_api.h;h=4f40fa520ab035a07c67c46edd22adaa31e2f069;hp=826f6cd198572b66b0192f8c26f46e431513f0ea;hb=39feb7a7e30bb4b393a6f76aa2f35d4e9275523e;hpb=ffc893b125c6cc9b385a68a357b08ba2cc4e91f6 diff --git a/php_http_api.h b/php_http_api.h index 826f6cd..4f40fa5 100644 --- a/php_http_api.h +++ b/php_http_api.h @@ -36,6 +36,29 @@ extern STATUS _http_parse_key_list(const char *list, HashTable *items, char sepa #define http_error_ex _http_error_ex extern void _http_error_ex(long type TSRMLS_DC, long code, const char *format, ...); +#define HTTP_CHECK_CURL_INIT(ch, init, action) \ + if ((!(ch)) && (!((ch) = init))) { \ + http_error(HE_WARNING, HTTP_E_REQUEST, "Could not initialize curl"); \ + action; \ + } +#define HTTP_CHECK_CONTENT_TYPE(ct, action) \ + if (!strchr((ct), '/')) { \ + http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, \ + "Content type \"%s\" does not seem to contain a primary and a secondary part", (ct)); \ + action; \ + } +#define HTTP_CHECK_MESSAGE_TYPE_RESPONSE(msg, action) \ + if (!HTTP_MSG_TYPE(RESPONSE, (msg))) { \ + http_error(HE_NOTICE, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_RESPONSE"); \ + action; \ + } +#define HTTP_CHECK_MESSAGE_TYPE_REQUEST(msg, action) \ + if (!HTTP_MSG_TYPE(REQUEST, (msg))) { \ + http_error(HE_NOTICE, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_REQUEST"); \ + action; \ + } + + #define http_log(f, i, m) _http_log_ex((f), (i), (m) TSRMLS_CC) extern void http_log_ex(char *file, const char *ident, const char *message TSRMLS_DC);