X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_request_api.h;h=bebceaebe8f90e49e1305af8c758d18ce2a86697;hp=318b6967690d6a97dca0ec84607f903fda41d1c8;hb=refs%2Fheads%2Fv1.7.x;hpb=16dba799dae126258bbb09e2f699d5d7954fac17 diff --git a/php_http_request_api.h b/php_http_request_api.h index 318b696..bebceae 100644 --- a/php_http_request_api.h +++ b/php_http_request_api.h @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2005, Michael Wallner | + | Copyright (c) 2004-2010, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -23,7 +23,7 @@ extern PHP_MINIT_FUNCTION(http_request); extern PHP_MSHUTDOWN_FUNCTION(http_request); -typedef struct { +typedef struct _http_request_t { CURL *ch; char *url; http_request_method meth; @@ -41,6 +41,11 @@ typedef struct { struct curl_slist *headers; } _cache; + struct { + uint count; + double delay; + } _retry; + char _error[CURL_ERROR_SIZE+1]; zval *_progress_callback; @@ -48,8 +53,45 @@ typedef struct { void ***tsrm_ls; #endif + uint _in_progress_cb:1; + } http_request; +#ifndef pestrndup +# define pestrndup(s,l,p) _pestrndup((s),(l),(p)) +static inline void *_pestrndup(const void *s, size_t l, int p) +{ + void *d = pemalloc(l+1, p); + memcpy(d, s, l); + ((char *) d)[l] = '\0'; + return d; +} +#endif + +/* CURLOPT_PRIVATE storage living as long as a CURL handle */ +typedef struct _http_request_storage_t { + char *url; + char *cookiestore; + char errorbuffer[CURL_ERROR_SIZE]; +} http_request_storage; + +static inline http_request_storage *http_request_storage_get(CURL *ch) +{ + http_request_storage *st = NULL; + curl_easy_getinfo(ch, CURLINFO_PRIVATE, &st); + return st; +} + +#define http_curl_init(r) http_curl_init_ex(NULL, (r)) +#define http_curl_init_ex(c, r) _http_curl_init_ex((c), (r) TSRMLS_CC) +PHP_HTTP_API CURL *_http_curl_init_ex(CURL *ch, http_request *request TSRMLS_DC); + +#define http_curl_free(c) _http_curl_free((c) TSRMLS_CC) +PHP_HTTP_API void _http_curl_free(CURL **ch TSRMLS_DC); + +#define http_curl_copy(c) _http_curl_copy((c) TSRMLS_CC) +PHP_HTTP_API CURL *_http_curl_copy(CURL *ch TSRMLS_DC); + #define http_request_new() _http_request_init_ex(NULL, NULL, 0, NULL ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC) #define http_request_init(r) _http_request_init_ex((r), NULL, 0, NULL ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC) #define http_request_init_ex(r, c, m, u) _http_request_init_ex((r), (c), (m), (u) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC) @@ -64,6 +106,15 @@ PHP_HTTP_API void _http_request_free(http_request **request); #define http_request_reset(r) _http_request_reset(r) PHP_HTTP_API void _http_request_reset(http_request *r); +#define http_request_enable_cookies(r) _http_request_enable_cookies(r) +PHP_HTTP_API STATUS _http_request_enable_cookies(http_request *request); + +#define http_request_reset_cookies(r, s) _http_request_reset_cookies((r), (s)) +PHP_HTTP_API STATUS _http_request_reset_cookies(http_request *request, int session_only); + +#define http_request_flush_cookies(r) _http_request_flush_cookies(r) +PHP_HTTP_API STATUS _http_request_flush_cookies(http_request *request); + #define http_request_defaults(r) _http_request_defaults(r) PHP_HTTP_API void _http_request_defaults(http_request *request);