-
-#ifdef ZEND_ENGINE_2
-
-/* {{{ HttpUtil */
-
-zend_class_entry *http_util_ce;
-
-#define HTTP_UTIL_ME(me, al, ai) ZEND_FENTRY(me, ZEND_FN(al), ai, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
-
-zend_function_entry http_util_class_methods[] = {
- HTTP_UTIL_ME(date, http_date, NULL)
- HTTP_UTIL_ME(absoluteURI, http_absolute_uri, NULL)
- HTTP_UTIL_ME(negotiateLanguage, http_negotiate_language, NULL)
- HTTP_UTIL_ME(negotiateCharset, http_negotiate_charset, NULL)
- HTTP_UTIL_ME(redirect, http_redirect, NULL)
- HTTP_UTIL_ME(sendStatus, http_send_status, NULL)
- HTTP_UTIL_ME(sendLastModified, http_send_last_modified, NULL)
- HTTP_UTIL_ME(sendContentType, http_send_content_type, NULL)
- HTTP_UTIL_ME(sendContentDisposition, http_send_content_disposition, NULL)
- HTTP_UTIL_ME(matchModified, http_match_modified, NULL)
- HTTP_UTIL_ME(matchEtag, http_match_etag, NULL)
- HTTP_UTIL_ME(cacheLastModified, http_cache_last_modified, NULL)
- HTTP_UTIL_ME(cacheEtag, http_cache_etag, NULL)
- HTTP_UTIL_ME(chunkedDecode, http_chunked_decode, NULL)
- HTTP_UTIL_ME(splitResponse, http_split_response, NULL)
- HTTP_UTIL_ME(parseHeaders, http_parse_headers, NULL)
- HTTP_UTIL_ME(getRequestHeaders, http_get_request_headers, NULL)
-#ifdef HTTP_HAVE_CURL
- HTTP_UTIL_ME(get, http_get, http_request_info_ref_3)
- HTTP_UTIL_ME(head, http_head, http_request_info_ref_3)
- HTTP_UTIL_ME(postData, http_post_data, http_request_info_ref_4)
- HTTP_UTIL_ME(postArray, http_post_array, http_request_info_ref_4)
-#endif
- HTTP_UTIL_ME(authBasic, http_auth_basic, NULL)
- HTTP_UTIL_ME(authBasicCallback, http_auth_basic_cb, NULL)
- {NULL, NULL, NULL}
-};
-/* }}} HttpUtil */
-
-/* {{{ HttpResponse */
-
-zend_class_entry *http_response_ce;
-static zend_object_handlers http_response_object_handlers;
-
-#define http_response_declare_default_properties(ce) _http_response_declare_default_properties(ce TSRMLS_CC)
-static inline void _http_response_declare_default_properties(zend_class_entry *ce TSRMLS_DC)
-{
- DCL_PROP(PROTECTED, string, contentType, "application/x-octetstream");
- DCL_PROP(PROTECTED, string, eTag, "");
- DCL_PROP(PROTECTED, string, dispoFile, "");
- DCL_PROP(PROTECTED, string, cacheControl, "public");
- DCL_PROP(PROTECTED, string, data, "");
- DCL_PROP(PROTECTED, string, file, "");
- DCL_PROP(PROTECTED, long, stream, 0);
- DCL_PROP(PROTECTED, long, lastModified, 0);
- DCL_PROP(PROTECTED, long, dispoInline, 0);
- DCL_PROP(PROTECTED, long, cache, 0);
- DCL_PROP(PROTECTED, long, gzip, 0);
-
- DCL_PROP(PRIVATE, long, raw_cache_header, 0);
- DCL_PROP(PRIVATE, long, send_mode, -1);
-}
-
-#define http_response_destroy_object _http_response_destroy_object
-void _http_response_destroy_object(void *object, zend_object_handle handle TSRMLS_DC)
-{
- http_response_object *o = object;
- if (OBJ_PROP(o)) {
- zend_hash_destroy(OBJ_PROP(o));
- FREE_HASHTABLE(OBJ_PROP(o));
- }
- efree(o);
-}
-
-#define http_response_new_object _http_response_new_object
-zend_object_value _http_response_new_object(zend_class_entry *ce TSRMLS_DC)
-{
- zend_object_value ov;
- http_response_object *o;
-
- o = ecalloc(1, sizeof(http_response_object));
- o->zo.ce = ce;
-
- ALLOC_HASHTABLE(OBJ_PROP(o));
- zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
- zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
-
- ov.handle = zend_objects_store_put(o, http_response_destroy_object, NULL, NULL TSRMLS_CC);
- ov.handlers = &http_response_object_handlers;
-
- return ov;
-}
-
-zend_function_entry http_response_class_methods[] = {
- PHP_ME(HttpResponse, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
-/* PHP_ME(HttpResponse, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
-*/
- PHP_ME(HttpResponse, setETag, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getETag, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setContentDisposition, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getContentDisposition, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setContentType, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getContentType, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setCache, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getCache, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setCacheControl, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getCacheControl, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setGzip, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getGzip, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setData, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getData, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setFile, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getFile, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setStream, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getStream, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, send, NULL, ZEND_ACC_PUBLIC)
-
- {NULL, NULL, NULL}
-};
-/* }}} */
-
-/* {{{ HttpRequest */
-#ifdef HTTP_HAVE_CURL
-
-zend_class_entry *http_request_ce;
-static zend_object_handlers http_request_object_handlers;
-
-#define http_request_declare_default_properties(ce) _http_request_declare_default_properties(ce TSRMLS_CC)
-static inline void _http_request_declare_default_properties(zend_class_entry *ce TSRMLS_DC)
-{
- DCL_PROP_N(PROTECTED, options);
- DCL_PROP_N(PROTECTED, responseInfo);
- DCL_PROP_N(PROTECTED, responseData);
- DCL_PROP_N(PROTECTED, postData);
- DCL_PROP_N(PROTECTED, postFiles);
-
- DCL_PROP(PROTECTED, long, method, HTTP_GET);
-
- DCL_PROP(PROTECTED, string, url, "");
- DCL_PROP(PROTECTED, string, contentType, "");
- DCL_PROP(PROTECTED, string, queryData, "");
- DCL_PROP(PROTECTED, string, postData, "");
-}
-
-#define http_request_free_object _http_request_free_object
-void _http_request_free_object(zend_object /* void */ *object TSRMLS_DC)
-{
- http_request_object *o = (http_request_object *) object;
-
- if (OBJ_PROP(o)) {
- zend_hash_destroy(OBJ_PROP(o));
- FREE_HASHTABLE(OBJ_PROP(o));
- }
- if (o->ch) {
- curl_easy_cleanup(o->ch);
- o->ch = NULL;
- }
- efree(o);
-}
-
-#define http_request_new_object _http_request_new_object
-zend_object_value _http_request_new_object(zend_class_entry *ce TSRMLS_DC)
-{
- zend_object_value ov;
- http_request_object *o;
-
- o = ecalloc(1, sizeof(http_request_object));
- o->zo.ce = ce;
- o->ch = curl_easy_init();
-
- ALLOC_HASHTABLE(OBJ_PROP(o));
- zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
- zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
-
- ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_request_free_object, NULL TSRMLS_CC);
- ov.handlers = &http_request_object_handlers;
-
- return ov;
-}
-
-zend_function_entry http_request_class_methods[] = {
- PHP_ME(HttpRequest, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
- PHP_ME(HttpRequest, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
-
- PHP_ME(HttpRequest, setOptions, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getOptions, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, unsetOptions, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpRequest, addHeader, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, addCookie, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpRequest, setMethod, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getMethod, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpRequest, setURL, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getURL, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpRequest, setContentType, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getContentType, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpRequest, setQueryData, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getQueryData, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, addQueryData, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, unsetQueryData, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpRequest, setPostData, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getPostData, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, addPostData, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, unsetPostData, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpRequest, addPostFile, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getPostFiles, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, unsetPostFiles, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpRequest, send, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpRequest, getResponseData, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getResponseHeader, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getResponseCode, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getResponseBody, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpRequest, getResponseInfo, NULL, ZEND_ACC_PUBLIC)
-
- {NULL, NULL, NULL}