memset(h, 0, sizeof(*h));
h->ops = ops;
- h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
+ if (rf) {
+ h->rf = rf;
+ } else if (ops->rsrc) {
+ h->rf = php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
+ }
h->buffer = php_http_buffer_init(NULL);
h->parser = php_http_message_parser_init(NULL TSRMLS_CC);
h->message = php_http_message_init(NULL, 0 TSRMLS_CC);
if (from->rf) {
php_http_resource_factory_addref(from->rf);
to->rf = from->rf;
- } else {
+ } else if (to->ops->rsrc){
to->rf = php_http_resource_factory_init(NULL, to->ops->rsrc, to, NULL);
}
to->buffer = php_http_buffer_init(NULL);
PHP_HTTP_END_ARGS;
PHP_HTTP_EMPTY_ARGS(getRequest);
-PHP_HTTP_BEGIN_ARGS(send, 1)
- PHP_HTTP_ARG_VAL(request, 0)
-PHP_HTTP_END_ARGS;
-
PHP_HTTP_EMPTY_ARGS(getObservers);
PHP_HTTP_BEGIN_ARGS(attach, 1)
PHP_HTTP_ARG_OBJ(SplObserver, observer, 0)
PHP_HTTP_END_ARGS;
-zend_class_entry *php_http_client_class_entry;
-zend_function_entry php_http_client_method_entry[] = {
+static zend_class_entry *php_http_client_class_entry;
+
+zend_class_entry *php_http_client_get_class_entry(void)
+{
+ return php_http_client_class_entry;
+}
+
+static zend_function_entry php_http_client_method_entry[] = {
PHP_HTTP_CLIENT_ME(__construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_HTTP_CLIENT_ME(getObservers, ZEND_ACC_PUBLIC)
PHP_HTTP_CLIENT_ME(notify, ZEND_ACC_PUBLIC)
PHP_HTTP_CLIENT_ME(setRequest, ZEND_ACC_PUBLIC)
PHP_HTTP_CLIENT_ME(getRequest, ZEND_ACC_PUBLIC)
- PHP_HTTP_CLIENT_ME(send, ZEND_ACC_PUBLIC)
PHP_HTTP_CLIENT_ME(getResponseMessage, ZEND_ACC_PUBLIC)
PHP_HTTP_CLIENT_ME(getRequestMessage, ZEND_ACC_PUBLIC)
return &php_http_client_object_handlers;
}
+static php_http_client_ops_t php_http_client_user_ops = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ (php_http_new_t) php_http_client_object_new_ex,
+ php_http_client_get_class_entry
+};
+
zend_object_value php_http_client_object_new(zend_class_entry *ce TSRMLS_DC)
{
return php_http_client_object_new_ex(ce, NULL, NULL TSRMLS_CC);
zend_object_value ov;
php_http_client_object_t *o;
- o = ecalloc(1, sizeof(php_http_client_object_t));
+ o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
object_properties_init((zend_object *) o, ce);
+ ov.handle = zend_objects_store_put(o, NULL, php_http_client_object_free, NULL TSRMLS_CC);
+ ov.handlers = &php_http_client_object_handlers;
+
if (!(o->client = r)) {
- o->client = php_http_client_init(NULL, NULL, NULL, NULL TSRMLS_CC);
+ o->client = php_http_client_init(NULL, &php_http_client_user_ops, NULL, &ov TSRMLS_CC);
}
if (ptr) {
*ptr = o;
}
- ov.handle = zend_objects_store_put(o, NULL, php_http_client_object_free, NULL TSRMLS_CC);
- ov.handlers = &php_http_client_object_handlers;
-
return ov;
}
efree(o);
}
-static inline void php_http_client_object_check_request_content_type(zval *this_ptr TSRMLS_DC)
-{
- zval *ctype = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("contentType"), 0 TSRMLS_CC);
-
- if (Z_STRLEN_P(ctype)) {
- zval **headers, *opts = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC);
-
- if ( (Z_TYPE_P(opts) == IS_ARRAY) &&
- (SUCCESS == zend_hash_find(Z_ARRVAL_P(opts), ZEND_STRS("headers"), (void *) &headers)) &&
- (Z_TYPE_PP(headers) == IS_ARRAY)) {
- zval **ct_header;
-
- /* only override if not already set */
- if ((SUCCESS != zend_hash_find(Z_ARRVAL_PP(headers), ZEND_STRS("Content-Type"), (void *) &ct_header))) {
- add_assoc_stringl(*headers, "Content-Type", Z_STRVAL_P(ctype), Z_STRLEN_P(ctype), 1);
- } else
- /* or not a string, zero length string or a string of spaces */
- if ((Z_TYPE_PP(ct_header) != IS_STRING) || !Z_STRLEN_PP(ct_header)) {
- add_assoc_stringl(*headers, "Content-Type", Z_STRVAL_P(ctype), Z_STRLEN_P(ctype), 1);
- } else {
- int i, only_space = 1;
-
- /* check for spaces only */
- for (i = 0; i < Z_STRLEN_PP(ct_header); ++i) {
- if (!PHP_HTTP_IS_CTYPE(space, Z_STRVAL_PP(ct_header)[i])) {
- only_space = 0;
- break;
- }
- }
- if (only_space) {
- add_assoc_stringl(*headers, "Content-Type", Z_STRVAL_P(ctype), Z_STRLEN_P(ctype), 1);
- }
- }
- } else {
- zval *headers;
-
- MAKE_STD_ZVAL(headers);
- array_init(headers);
- add_assoc_stringl(headers, "Content-Type", Z_STRVAL_P(ctype), Z_STRLEN_P(ctype), 1);
- zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "addheaders", NULL, headers);
- zval_ptr_dtor(&headers);
- }
- }
-}
-
static inline zend_object_value php_http_client_object_message(zval *this_ptr, php_http_message_t *msg TSRMLS_DC)
{
zend_object_value ov;
return SUCCESS;
}
-STATUS php_http_client_object_requesthandler(php_http_client_object_t *obj, zval *this_ptr, char **meth, char **url, php_http_message_body_t **body TSRMLS_DC)
-{
- zval *zoptions;
- php_http_client_progress_t *progress;
-
- /* reset request handle */
- php_http_client_reset(obj->client);
- /* reset transfer info */
- zend_update_property_null(php_http_client_class_entry, getThis(), ZEND_STRL("info") TSRMLS_CC);
-
- if (meth) {
- *meth = Z_STRVAL_P(zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("method"), 0 TSRMLS_CC));
- }
-
- if (url) {
- php_url *tmp, qdu = {NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL};
- zval *zurl = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("url"), 0 TSRMLS_CC);
- zval *zqdata = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("queryData"), 0 TSRMLS_CC);
-
- if (Z_STRLEN_P(zqdata)) {
- qdu.query = Z_STRVAL_P(zqdata);
- }
- php_http_url(0, tmp = php_url_parse(Z_STRVAL_P(zurl)), &qdu, NULL, url, NULL TSRMLS_CC);
- php_url_free(tmp);
- }
-
- if (body) {
- zval *zbody = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("requestBody"), 0 TSRMLS_CC);
-
- if (Z_TYPE_P(zbody) == IS_OBJECT) {
- *body = ((php_http_message_body_object_t *)zend_object_store_get_object(zbody TSRMLS_CC))->body;
- if (*body) {
- php_stream_rewind(php_http_message_body_stream(*body));
- }
- }
- }
-
- php_http_client_object_check_request_content_type(getThis() TSRMLS_CC);
- zoptions = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC);
- php_http_client_setopt(obj->client, PHP_HTTP_CLIENT_OPT_SETTINGS, Z_ARRVAL_P(zoptions));
-
- if (SUCCESS == php_http_client_getopt(obj->client, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO, &progress)) {
- if (!progress->callback) {
- php_http_client_progress_callback_t *callback = emalloc(sizeof(*callback));
-
- callback->type = PHP_HTTP_CLIENT_PROGRESS_CALLBACK_USER;
- callback->pass_state = 0;
- MAKE_STD_ZVAL(callback->func.user);
- array_init(callback->func.user);
- Z_ADDREF_P(getThis());
- add_next_index_zval(callback->func.user, getThis());
- add_next_index_stringl(callback->func.user, ZEND_STRL("notify"), 1);
-
- php_http_client_setopt(obj->client, PHP_HTTP_CLIENT_OPT_PROGRESS_CALLBACK, callback);
- }
- progress->state.info = "start";
- php_http_client_progress_notify(progress TSRMLS_CC);
- progress->state.started = 1;
- }
- return SUCCESS;
-}
-
-static inline void empty_response(zval *this_ptr TSRMLS_DC)
-{
- zend_update_property_null(php_http_client_class_entry, getThis(), ZEND_STRL("responseMessage") TSRMLS_CC);
-}
STATUS php_http_client_object_handle_response(zval *zclient TSRMLS_DC)
{
return SUCCESS;
}
-STATUS php_http_client_object_responsehandler(php_http_client_object_t *obj, zval *this_ptr TSRMLS_DC)
-{
- STATUS ret = SUCCESS;
- zval *info;
- php_http_message_t *msg;
- php_http_client_progress_t *progress;
-
- /* always fetch info */
- MAKE_STD_ZVAL(info);
- array_init(info);
- php_http_client_getopt(obj->client, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO, Z_ARRVAL_P(info));
- zend_update_property(php_http_client_class_entry, getThis(), ZEND_STRL("transferInfo"), info TSRMLS_CC);
- zval_ptr_dtor(&info);
-
- if ((msg = obj->client->message)) {
- /* update history */
- if (i_zend_is_true(zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("recordHistory"), 0 TSRMLS_CC))) {
- zval *new_hist, *old_hist = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("history"), 0 TSRMLS_CC);
- zend_object_value ov = php_http_client_object_message(getThis(), php_http_message_copy(msg, NULL) TSRMLS_CC);
-
- MAKE_STD_ZVAL(new_hist);
- ZVAL_OBJVAL(new_hist, ov, 0);
-
- if (Z_TYPE_P(old_hist) == IS_OBJECT) {
- php_http_message_object_prepend(new_hist, old_hist, 1 TSRMLS_CC);
- }
-
- zend_update_property(php_http_client_class_entry, getThis(), ZEND_STRL("history"), new_hist TSRMLS_CC);
- zval_ptr_dtor(&new_hist);
- }
-
- /* update response info */
- if (PHP_HTTP_MESSAGE_TYPE(RESPONSE, msg)) {
- zval *message;
-
- MAKE_STD_ZVAL(message);
- ZVAL_OBJVAL(message, php_http_client_object_message(getThis(), msg TSRMLS_CC), 0);
- zend_update_property(php_http_client_class_entry, getThis(), ZEND_STRL("responseMessage"), message TSRMLS_CC);
- zval_ptr_dtor(&message);
-
- obj->client->message = php_http_message_init(NULL, 0 TSRMLS_CC);
- msg = msg->parent;
- } else {
- empty_response(getThis() TSRMLS_CC);
- }
- } else {
- /* update properties with empty values */
- empty_response(getThis() TSRMLS_CC);
- }
-
- while (msg && !PHP_HTTP_MESSAGE_TYPE(REQUEST, msg)) {
- msg = msg->parent;
- }
- if (PHP_HTTP_MESSAGE_TYPE(REQUEST, msg)) {
- zval *message;
-
- MAKE_STD_ZVAL(message);
- ZVAL_OBJVAL(message, php_http_client_object_message(getThis(), php_http_message_copy_ex(msg, NULL, 0) TSRMLS_CC), 0);
- zend_update_property(php_http_client_class_entry, getThis(), ZEND_STRL("requestMessage"), message TSRMLS_CC);
- zval_ptr_dtor(&message);
- }
-
- if (SUCCESS == php_http_client_getopt(obj->client, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO, &progress)) {
- progress->state.info = "finished";
- progress->state.finished = 1;
- php_http_client_progress_notify(progress TSRMLS_CC);
- }
- php_http_client_setopt(obj->client, PHP_HTTP_CLIENT_OPT_PROGRESS_CALLBACK, NULL);
-
- return ret;
-}
-
static int apply_pretty_key(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
zval **zpp = pDest, *arr = va_arg(args, zval *);
{
if (SUCCESS == zend_parse_parameters_none()) {
php_http_client_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
- php_http_client_progress_t *progress;
-
- php_http_client_getopt(obj->client, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO, &progress);
- object_init(return_value);
- add_property_bool(return_value, "started", progress->state.started);
- add_property_bool(return_value, "finished", progress->state.finished);
- add_property_string(return_value, "info", STR_PTR(progress->state.info), 1);
- add_property_double(return_value, "dltotal", progress->state.dl.total);
- add_property_double(return_value, "dlnow", progress->state.dl.now);
- add_property_double(return_value, "ultotal", progress->state.ul.total);
- add_property_double(return_value, "ulnow", progress->state.ul.now);
+ php_http_client_progress_t *progress = NULL;
+
+ if (SUCCESS == php_http_client_getopt(obj->client, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO, &progress)) {
+ object_init(return_value);
+ add_property_bool(return_value, "started", progress->state.started);
+ add_property_bool(return_value, "finished", progress->state.finished);
+ add_property_string(return_value, "info", STR_PTR(progress->state.info), 1);
+ add_property_double(return_value, "dltotal", progress->state.dl.total);
+ add_property_double(return_value, "dlnow", progress->state.dl.now);
+ add_property_double(return_value, "ultotal", progress->state.ul.total);
+ add_property_double(return_value, "ulnow", progress->state.ul.now);
+ }
}
}
PHP_MINIT_FUNCTION(http_client)
{
PHP_HTTP_REGISTER_CLASS(http\\Client, AbstractClient, http_client, php_http_object_class_entry, ZEND_ACC_ABSTRACT);
- php_http_client_class_entry->create_object = php_http_object_new;//php_http_client_object_new;
+ php_http_client_class_entry->create_object = php_http_client_object_new;
memcpy(&php_http_client_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_http_client_object_handlers.clone_obj = php_http_client_object_clone;
php_http_client_t *client;
} php_http_client_object_t;
-extern zend_class_entry *php_http_client_class_entry;
-extern zend_function_entry php_http_client_method_entry[];
+zend_object_value php_http_client_object_new(zend_class_entry *ce TSRMLS_DC);
+zend_object_value php_http_client_object_new_ex(zend_class_entry *ce, php_http_client_t *r, php_http_client_object_t **ptr TSRMLS_DC);
+zend_object_value php_http_client_object_clone(zval *zobject TSRMLS_DC);
+void php_http_client_object_free(void *object TSRMLS_DC);
-extern zend_object_value php_http_client_object_new(zend_class_entry *ce TSRMLS_DC);
-extern zend_object_value php_http_client_object_new_ex(zend_class_entry *ce, php_http_client_t *r, php_http_client_object_t **ptr TSRMLS_DC);
-extern zend_object_value php_http_client_object_clone(zval *zobject TSRMLS_DC);
-extern void php_http_client_object_free(void *object TSRMLS_DC);
+zend_class_entry *php_http_client_get_class_entry(void);
+zend_object_handlers *php_http_client_get_object_handlers(void);
-extern zend_object_handlers *php_http_client_get_object_handlers(void);
+STATUS php_http_client_object_handle_request(zval *zclient, zval **zreq TSRMLS_DC);
+STATUS php_http_client_object_handle_response(zval *zclient TSRMLS_DC);
-extern STATUS php_http_client_object_handle_request(zval *zclient, zval **zreq TSRMLS_DC);
-extern STATUS php_http_client_object_handle_response(zval *zclient TSRMLS_DC);
-
-extern STATUS php_http_client_object_requesthandler(php_http_client_object_t *obj, zval *this_ptr, char **meth, char **url, php_http_message_body_t **body TSRMLS_DC);
-extern STATUS php_http_client_object_responsehandler(php_http_client_object_t *obj, zval *this_ptr TSRMLS_DC);
+STATUS php_http_client_object_requesthandler(php_http_client_object_t *obj, zval *this_ptr, char **meth, char **url, php_http_message_body_t **body TSRMLS_DC);
+STATUS php_http_client_object_responsehandler(php_http_client_object_t *obj, zval *this_ptr TSRMLS_DC);
PHP_METHOD(HttpClient, __construct);
PHP_METHOD(HttpClient, getObservers);
PHP_METHOD(HttpClient, getResponseMessageClass);
PHP_METHOD(HttpClient, setResponseMessageClass);
-extern PHP_MINIT_FUNCTION(http_client);
+PHP_MINIT_FUNCTION(http_client);
#endif
}
-#define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpClientCURL, method, 0, req_args)
-#define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpClientCURL, method, 0)
-#define PHP_HTTP_CURL_ME(method, visibility) PHP_ME(HttpClientCURL, method, PHP_HTTP_ARGS(HttpClientCURL, method), visibility)
-#define PHP_HTTP_CURL_ALIAS(method, func) PHP_HTTP_STATIC_ME_ALIAS(method, func, PHP_HTTP_ARGS(HttpClientCURL, method))
-#define PHP_HTTP_CURL_MALIAS(me, al, vis) ZEND_FENTRY(me, ZEND_MN(HttpClientCURL_##al), PHP_HTTP_ARGS(HttpClientCURL, al), vis)
+#define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpClientCURL, method, 0, req_args)
+#define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpClientCURL, method, 0)
+#define PHP_HTTP_CLIENT_CURL_ME(method, visibility) PHP_ME(HttpClientCURL, method, PHP_HTTP_ARGS(HttpClientCURL, method), visibility)
+#define PHP_HTTP_CLIENT_CURL_CLIENT_MALIAS(me, vis) ZEND_FENTRY(me, ZEND_MN(HttpClient_##me), PHP_HTTP_ARGS(HttpClientCURL, me), vis)
+PHP_HTTP_BEGIN_ARGS(send, 1)
+ PHP_HTTP_ARG_VAL(request, 0)
+PHP_HTTP_END_ARGS;
zend_class_entry *php_http_client_curl_class_entry;
zend_function_entry php_http_client_curl_method_entry[] = {
+ PHP_HTTP_CLIENT_CURL_CLIENT_MALIAS(send, ZEND_ACC_PUBLIC)
EMPTY_FUNCTION_ENTRY
};
return FAILURE;
}
- PHP_HTTP_REGISTER_CLASS(http\\Client, CURL, http_client_curl, php_http_client_class_entry, 0);
+ PHP_HTTP_REGISTER_CLASS(http\\Client, CURL, http_client_curl, php_http_client_get_class_entry(), 0);
php_http_client_curl_class_entry->create_object = php_http_client_curl_object_new;
/*
zend_llist_init(&h->clients, sizeof(zval *), ZVAL_PTR_DTOR, 0);
h->ops = ops;
- h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL);
+ if (rf) {
+ h->rf = rf;
+ } else if (ops->rsrc) {
+ h->rf = php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
+ }
TSRMLS_SET_CTX(h->ts);
if (h->ops->init) {
static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value, const zend_literal *literal_key TSRMLS_DC);
-zend_class_entry *php_http_client_datashare_class_entry;
-zend_function_entry php_http_client_datashare_method_entry[] = {
+static zend_class_entry *php_http_client_datashare_class_entry;
+
+zend_class_entry *php_http_client_datashare_get_class_entry(void)
+{
+ return php_http_client_datashare_class_entry;
+}
+
+static zend_function_entry php_http_client_datashare_method_entry[] = {
PHP_HTTP_RSHARE_ME(__destruct, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
PHP_HTTP_RSHARE_ME(count, ZEND_ACC_PUBLIC)
PHP_HTTP_RSHARE_ME(attach, ZEND_ACC_PUBLIC)
{
return &php_http_client_datashare_object_handlers;
}
+static STATUS setopt(struct php_http_client_datashare *h, php_http_client_datashare_setopt_opt_t opt, void *arg)
+{
+ return SUCCESS;
+}
+static php_http_client_datashare_ops_t php_http_client_datashare_user_ops = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ setopt,
+ (php_http_new_t) php_http_client_datashare_object_new_ex,
+ php_http_client_datashare_get_class_entry
+
+};
zend_object_value php_http_client_datashare_object_new(zend_class_entry *ce TSRMLS_DC)
{
return php_http_client_datashare_object_new_ex(ce, NULL, NULL TSRMLS_CC);
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
object_properties_init((zend_object *) o, ce);
- if (share) {
- o->share = share;
- } else {
- o->share = php_http_client_datashare_init(NULL, NULL, NULL, NULL TSRMLS_CC);
+ ov.handle = zend_objects_store_put(o, NULL, php_http_client_datashare_object_free, NULL TSRMLS_CC);
+ ov.handlers = &php_http_client_datashare_object_handlers;
+
+ if (!(o->share = share)) {
+ o->share = php_http_client_datashare_init(NULL, &php_http_client_datashare_user_ops, NULL, &ov TSRMLS_CC);
}
if (ptr) {
*ptr = o;
}
- ov.handle = zend_objects_store_put(o, NULL, php_http_client_datashare_object_free, NULL TSRMLS_CC);
- ov.handlers = &php_http_client_datashare_object_handlers;
-
return ov;
}
{
zval *client;
- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &client, php_http_client_class_entry)) {
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &client, php_http_client_get_class_entry())) {
php_http_client_datashare_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
RETURN_SUCCESS(php_http_client_datashare_attach(obj->share, client));
{
zval *client;
- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &client, php_http_client_class_entry)) {
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &client, php_http_client_get_class_entry())) {
php_http_client_datashare_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
RETURN_SUCCESS(php_http_client_datashare_detach(obj->share, client));
PHP_MINIT_FUNCTION(http_client_datashare)
{
PHP_HTTP_REGISTER_CLASS(http\\Client\\DataShare, AbstractDataShare, http_client_datashare, php_http_object_class_entry, 0);
- php_http_client_datashare_class_entry->create_object = php_http_object_new;//php_http_client_datashare_object_new;
+ php_http_client_datashare_class_entry->create_object = php_http_client_datashare_object_new;
memcpy(&php_http_client_datashare_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_http_client_datashare_object_handlers.clone_obj = NULL;
php_http_client_datashare_object_handlers.write_property = php_http_client_datashare_object_write_prop;
#endif
} php_http_client_datashare_t;
-extern PHP_MINIT_FUNCTION(http_client_datashare);
+PHP_MINIT_FUNCTION(http_client_datashare);
PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC);
PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_copy(php_http_client_datashare_t *from, php_http_client_datashare_t *to);
php_http_client_datashare_t *share;
} php_http_client_datashare_object_t;
-extern zend_class_entry *php_http_client_datashare_class_entry;
-extern zend_function_entry php_http_client_datashare_method_entry[];
+zend_object_value php_http_client_datashare_object_new(zend_class_entry *ce TSRMLS_DC);
+zend_object_value php_http_client_datashare_object_new_ex(zend_class_entry *ce, php_http_client_datashare_t *share, php_http_client_datashare_object_t **ptr TSRMLS_DC);
+void php_http_client_datashare_object_free(void *object TSRMLS_DC);
-extern zend_object_value php_http_client_datashare_object_new(zend_class_entry *ce TSRMLS_DC);
-extern zend_object_value php_http_client_datashare_object_new_ex(zend_class_entry *ce, php_http_client_datashare_t *share, php_http_client_datashare_object_t **ptr TSRMLS_DC);
-extern void php_http_client_datashare_object_free(void *object TSRMLS_DC);
-
-extern zend_object_handlers *php_http_client_datashare_get_object_handlers(void);
+zend_class_entry *php_http_client_datashare_get_class_entry();
+zend_object_handlers *php_http_client_datashare_get_object_handlers(void);
PHP_METHOD(HttpClientDataShare, __destruct);
PHP_METHOD(HttpClientDataShare, count);
return FAILURE;
}
- PHP_HTTP_REGISTER_CLASS(http\\Client\\DataShare, CURL, http_client_datashare_curl, php_http_client_datashare_class_entry, 0);
+ PHP_HTTP_REGISTER_CLASS(http\\Client\\DataShare, CURL, http_client_datashare_curl, php_http_client_datashare_get_class_entry(), 0);
php_http_client_datashare_curl_class_entry->create_object = php_http_client_datashare_curl_object_new;
return SUCCESS;
}
with_error_handling(EH_THROW, php_http_exception_class_entry) {
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!", &options)) {
with_error_handling(EH_THROW, php_http_exception_class_entry) {
- zval *zdriver, *os;
+ zval *zdriver;
zend_object_value ov;
zend_class_entry *class_entry = NULL;
php_http_client_t *req = NULL;
if (SUCCESS == php_http_new(&ov, class_entry, driver.client_pool_ops->create_object, driver.client_pool_ops->class_entry(), pool, NULL TSRMLS_CC)) {
ZVAL_OBJVAL(return_value, ov, 0);
for (i = 0; i < argc; ++i) {
- if (Z_TYPE_PP(argv[i]) == IS_OBJECT && instanceof_function(Z_OBJCE_PP(argv[i]), php_http_client_class_entry TSRMLS_CC)) {
+ if (Z_TYPE_PP(argv[i]) == IS_OBJECT && instanceof_function(Z_OBJCE_PP(argv[i]), php_http_client_get_class_entry() TSRMLS_CC)) {
php_http_client_pool_attach(pool, *(argv[i]));
}
}
if (SUCCESS == php_http_new(&ov, class_entry, driver.client_datashare_ops->create_object, driver.client_datashare_ops->class_entry(), share, NULL TSRMLS_CC)) {
ZVAL_OBJVAL(return_value, ov, 0);
for (i = 0; i < argc; ++i) {
- if (Z_TYPE_PP(argv[i]) == IS_OBJECT && instanceof_function(Z_OBJCE_PP(argv[i]), php_http_client_class_entry TSRMLS_CC)) {
+ if (Z_TYPE_PP(argv[i]) == IS_OBJECT && instanceof_function(Z_OBJCE_PP(argv[i]), php_http_client_get_class_entry() TSRMLS_CC)) {
php_http_client_datashare_attach(share, *(argv[i]));
}
}
memset(h, 0, sizeof(*h));
h->ops = ops;
- h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL);
+ if (rf) {
+ h->rf = rf;
+ } else if (ops->rsrc) {
+ h->rf = php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
+ }
zend_llist_init(&h->clients.attached, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0);
zend_llist_init(&h->clients.finished, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0);
TSRMLS_SET_CTX(h->ts);
PHP_HTTP_ARG_VAL(enable, 0)
PHP_HTTP_END_ARGS;
-zend_class_entry *php_http_client_pool_class_entry;
-zend_function_entry php_http_client_pool_method_entry[] = {
+static zend_class_entry *php_http_client_pool_class_entry;
+
+zend_class_entry *php_http_client_pool_get_class_entry(void)
+{
+ return php_http_client_pool_class_entry;
+}
+
+static zend_function_entry php_http_client_pool_method_entry[] = {
PHP_HTTP_CLIENT_POOL_ME(__destruct, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
PHP_HTTP_CLIENT_POOL_ME(attach, ZEND_ACC_PUBLIC)
PHP_HTTP_CLIENT_POOL_ME(detach, ZEND_ACC_PUBLIC)
return &php_http_client_pool_object_handlers;
}
+static php_http_client_pool_ops_t php_http_client_pool_user_ops = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ (php_http_new_t) php_http_client_pool_object_new_ex,
+ php_http_client_pool_get_class_entry
+};
+
zend_object_value php_http_client_pool_object_new(zend_class_entry *ce TSRMLS_DC)
{
return php_http_client_pool_object_new_ex(ce, NULL, NULL TSRMLS_CC);
object_properties_init((zend_object *) o, ce);
if (!(o->pool = p)) {
- o->pool = php_http_client_pool_init(NULL, NULL, NULL, NULL TSRMLS_CC);
+ o->pool = php_http_client_pool_init(NULL, &php_http_client_pool_user_ops, NULL, NULL TSRMLS_CC);
}
if (ptr) {
with_error_handling(EH_THROW, php_http_exception_class_entry) {
zval *request;
- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, php_http_client_class_entry)) {
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, php_http_client_get_class_entry())) {
with_error_handling(EH_THROW, php_http_exception_class_entry) {
php_http_client_pool_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
with_error_handling(EH_THROW, php_http_exception_class_entry) {
zval *request;
- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, php_http_client_class_entry)) {
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, php_http_client_get_class_entry())) {
with_error_handling(EH_THROW, php_http_exception_class_entry) {
php_http_client_pool_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
PHP_MINIT_FUNCTION(http_client_pool)
{
PHP_HTTP_REGISTER_CLASS(http\\Client\\Pool, AbstractPool, http_client_pool, php_http_object_class_entry, 0);
- php_http_client_pool_class_entry->create_object = php_http_object_new; //php_http_client_pool_object_new;
+ php_http_client_pool_class_entry->create_object = php_http_client_pool_object_new;
memcpy(&php_http_client_pool_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_http_client_pool_object_handlers.clone_obj = NULL;
- zend_declare_property_null(php_http_client_pool_class_entry, ZEND_STRL("client"), ZEND_ACC_PRIVATE TSRMLS_CC);
zend_class_implements(php_http_client_pool_class_entry TSRMLS_CC, 2, spl_ce_Countable, zend_ce_iterator);
return SUCCESS;
} iterator;
} php_http_client_pool_object_t;
-extern zend_class_entry *php_http_client_pool_class_entry;
-extern zend_function_entry php_http_client_pool_method_entry[];
+zend_object_value php_http_client_pool_object_new(zend_class_entry *ce TSRMLS_DC);
+zend_object_value php_http_client_pool_object_new_ex(zend_class_entry *ce, php_http_client_pool_t *p, php_http_client_pool_object_t **ptr TSRMLS_DC);
+void php_http_client_pool_object_free(void *object TSRMLS_DC);
-extern zend_object_value php_http_client_pool_object_new(zend_class_entry *ce TSRMLS_DC);
-extern zend_object_value php_http_client_pool_object_new_ex(zend_class_entry *ce, php_http_client_pool_t *p, php_http_client_pool_object_t **ptr TSRMLS_DC);
-extern void php_http_client_pool_object_free(void *object TSRMLS_DC);
-
-extern zend_object_handlers *php_http_client_pool_get_object_handlers(void);
+zend_class_entry *php_http_client_pool_get_class_entry(void);
+zend_object_handlers *php_http_client_pool_get_object_handlers(void);
PHP_METHOD(HttpClientPool, __destruct);
PHP_METHOD(HttpClientPool, attach);
return FAILURE;
}
- PHP_HTTP_REGISTER_CLASS(http\\Client\\Pool, CURL, http_client_pool_curl, php_http_client_pool_class_entry, 0);
+ PHP_HTTP_REGISTER_CLASS(http\\Client\\Pool, CURL, http_client_pool_curl, php_http_client_pool_get_class_entry(), 0);
php_http_client_pool_curl_class_entry->create_object = php_http_client_pool_curl_object_new;
return SUCCESS;
ZEND_INIT_SYMTABLE(¶ms);
if (php_http_params_parse(¶ms, &opts TSRMLS_CC)) {
- zval **zct;
char *key_str;
uint key_len;
ulong key_num;
PHP_METHOD(HttpMessage, toCallback)
{
- zend_bool include_parent = 0;
php_http_pass_fcall_arg_t fcd;
- long offset = 0, forlen = 0;
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fcd.fci, &fcd.fcc)) {
php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);