message->http.info.request.method = estrdup(Z_STRVAL_P(sval));
}
if ((sval = php_http_env_get_server_var(ZEND_STRL("REQUEST_URI"), 1))) {
- message->http.info.request.url = php_http_url_parse(Z_STRVAL_P(sval), Z_STRLEN_P(sval), ~0);
+ message->http.info.request.url = php_http_url_parse(Z_STRVAL_P(sval), Z_STRLEN_P(sval), PHP_HTTP_URL_STDFLAGS);
}
php_http_env_get_request_headers(&message->hdrs);
break;
case PHP_HTTP_RESPONSE:
- message = php_http_message_init(NULL, type, NULL);
+ message = php_http_message_init(message, type, NULL);
if (!SG(sapi_headers).http_status_line || !php_http_info_parse((php_http_info_t *) &message->http, SG(sapi_headers).http_status_line)) {
if (!(message->http.info.response.code = SG(sapi_headers).http_response_code)) {
message->http.info.response.code = 200;
popts.input.str = ct->val;
popts.input.len = ct->len;
- if (php_http_params_parse(¶ms, &popts)) {
+ if (EXPECTED(php_http_params_parse(¶ms, &popts))) {
zval *cur, *arg;
zend_string *ct_str;
zend_ulong index;
zend_hash_internal_pointer_reset(¶ms);
- if ((cur = zend_hash_get_current_data(¶ms))
+ if (EXPECTED((cur = zend_hash_get_current_data(¶ms))
&& (Z_TYPE_P(cur) == IS_ARRAY)
- && (HASH_KEY_IS_STRING == zend_hash_get_current_key(¶ms, &ct_str, &index))
+ && (HASH_KEY_IS_STRING == zend_hash_get_current_key(¶ms, &ct_str, &index)))
) {
if (php_http_match(ct_str->val, "multipart", PHP_HTTP_MATCH_WORD)) {
is_multipart = 1;
/* get boundary */
- if (boundary
+ if (EXPECTED(boundary
&& (arg = zend_hash_str_find(Z_ARRVAL_P(cur), ZEND_STRL("arguments")))
- && Z_TYPE_P(arg) == IS_ARRAY
+ && Z_TYPE_P(arg) == IS_ARRAY)
) {
zval *val;
php_http_arrkey_t key;
if (key.key && key.key->len == lenof("boundary") && !strcasecmp(key.key->val, "boundary")) {
zend_string *bnd = zval_get_string(val);
- if (bnd->len) {
+ if (EXPECTED(bnd->len)) {
*boundary = estrndup(bnd->val, bnd->len);
}
zend_string_release(bnd);
static void message_headers(php_http_message_t *msg, php_http_buffer_t *str)
{
char *tmp = NULL;
+ size_t len = 0;
- switch (msg->type) {
- case PHP_HTTP_REQUEST:
- php_http_buffer_appendf(str, PHP_HTTP_INFO_REQUEST_FMT_ARGS(&msg->http, tmp, PHP_HTTP_CRLF));
- PTR_FREE(tmp);
- break;
-
- case PHP_HTTP_RESPONSE:
- php_http_buffer_appendf(str, PHP_HTTP_INFO_RESPONSE_FMT_ARGS(&msg->http, tmp, PHP_HTTP_CRLF));
- PTR_FREE(tmp);
- break;
-
- default:
- break;
- }
-
+ php_http_info_to_string((php_http_info_t *) msg, &tmp, &len, PHP_HTTP_CRLF);
php_http_message_update_headers(msg);
+
+ php_http_buffer_append(str, tmp, len);
php_http_header_to_string(str, &msg->hdrs);
+ PTR_FREE(tmp);
}
void php_http_message_to_callback(php_http_message_t *msg, php_http_pass_callback_t cb, void *cb_arg)
if (c > 1) {
php_http_message_t *tmp = msg, **arr;
- arr = ecalloc(c, sizeof(**arr));
+ arr = ecalloc(c, sizeof(*arr));
for (i = 0; i < c; ++i) {
arr[i] = tmp;
tmp = tmp->parent;
void php_http_message_dtor(php_http_message_t *message)
{
- if (message) {
+ if (EXPECTED(message)) {
zend_hash_destroy(&message->hdrs);
php_http_message_body_free(&message->body);
void php_http_message_free(php_http_message_t **message)
{
- if (*message) {
+ if (EXPECTED(*message)) {
if ((*message)->parent) {
php_http_message_free(&(*message)->parent);
}
return php_http_message_class_entry;
}
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *rv);
-static void php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot);
+static zval *php_http_message_object_read_prop(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv);
+static zval *php_http_message_object_write_prop(zend_object *object, zend_string *member, zval *value, void **cache_slot);
static zend_object_handlers php_http_message_object_handlers;
static HashTable php_http_message_object_prophandlers;
return zend_hash_str_find_ptr(&php_http_message_object_prophandlers, name_str->val, name_str->len);
}
static void php_http_message_object_prophandler_get_type(php_http_message_object_t *obj, zval *return_value) {
+ zval_ptr_dtor(return_value);
RETVAL_LONG(obj->message->type);
}
static void php_http_message_object_prophandler_set_type(php_http_message_object_t *obj, zval *value) {
php_http_message_set_type(obj->message, zval_get_long(value));
}
static void php_http_message_object_prophandler_get_request_method(php_http_message_object_t *obj, zval *return_value) {
+ zval_ptr_dtor(return_value);
if (PHP_HTTP_MESSAGE_TYPE(REQUEST, obj->message) && obj->message->http.info.request.method) {
RETVAL_STRING(obj->message->http.info.request.method);
} else {
char *url_str;
size_t url_len;
+ zval_ptr_dtor(return_value);
if (PHP_HTTP_MESSAGE_TYPE(REQUEST, obj->message) && obj->message->http.info.request.url && php_http_url_to_string(obj->message->http.info.request.url, &url_str, &url_len, 0)) {
RETVAL_STR(php_http_cs2zs(url_str, url_len));
} else {
}
static void php_http_message_object_prophandler_set_request_url(php_http_message_object_t *obj, zval *value) {
if (PHP_HTTP_MESSAGE_TYPE(REQUEST, obj->message)) {
- PTR_SET(obj->message->http.info.request.url, php_http_url_from_zval(value, ~0));
+ PTR_SET(obj->message->http.info.request.url, php_http_url_from_zval(value, PHP_HTTP_URL_STDFLAGS));
}
}
static void php_http_message_object_prophandler_get_response_status(php_http_message_object_t *obj, zval *return_value) {
+ zval_ptr_dtor(return_value);
if (PHP_HTTP_MESSAGE_TYPE(RESPONSE, obj->message) && obj->message->http.info.response.status) {
RETVAL_STRING(obj->message->http.info.response.status);
} else {
}
}
static void php_http_message_object_prophandler_get_response_code(php_http_message_object_t *obj, zval *return_value) {
+ zval_ptr_dtor(return_value);
if (PHP_HTTP_MESSAGE_TYPE(RESPONSE, obj->message)) {
RETVAL_LONG(obj->message->http.info.response.code);
} else {
char *version_str;
size_t version_len;
+ zval_ptr_dtor(return_value);
php_http_version_to_string(&obj->message->http.version, &version_str, &version_len, NULL, NULL);
RETVAL_STR(php_http_cs2zs(version_str, version_len));
}
zend_string_release(zs);
}
static void php_http_message_object_prophandler_get_headers(php_http_message_object_t *obj, zval *return_value ) {
+ zval tmp;
+
+ ZVAL_COPY_VALUE(&tmp, return_value);
array_init(return_value);
array_copy(&obj->message->hdrs, Z_ARRVAL_P(return_value));
+ zval_ptr_dtor(&tmp);
}
static void php_http_message_object_prophandler_set_headers(php_http_message_object_t *obj, zval *value) {
- HashTable *headers;
- zval *orig_value = value;
+ int converted = 0;
+ HashTable garbage, *src;
if (Z_TYPE_P(value) != IS_ARRAY && Z_TYPE_P(value) != IS_OBJECT) {
- convert_to_array_ex(value);
+ converted = 1;
+ SEPARATE_ZVAL(value);
+ convert_to_array(value);
}
- headers = HASH_OF(value);
+ src = HASH_OF(value);
+
+ garbage = obj->message->hdrs;
+ zend_hash_init(&obj->message->hdrs, zend_hash_num_elements(src), NULL, ZVAL_PTR_DTOR, 0);
+ array_copy(HASH_OF(value), &obj->message->hdrs);
- zend_hash_clean(&obj->message->hdrs);
- array_copy(headers, &obj->message->hdrs);
+ zend_hash_destroy(&garbage);
- if (orig_value != value) {
+ if (converted) {
zval_ptr_dtor(value);
}
}
static void php_http_message_object_prophandler_get_body(php_http_message_object_t *obj, zval *return_value) {
if (obj->body) {
+ zval tmp;
+
+ ZVAL_COPY_VALUE(&tmp, return_value);
RETVAL_OBJECT(&obj->body->zo, 1);
+ zval_ptr_dtor(&tmp);
} else {
RETVAL_NULL();
}
}
static void php_http_message_object_prophandler_get_parent_message(php_http_message_object_t *obj, zval *return_value) {
if (obj->message->parent) {
+ zval tmp;
+
+ ZVAL_COPY_VALUE(&tmp, return_value);
RETVAL_OBJECT(&obj->parent->zo, 1);
+ zval_ptr_dtor(&tmp);
} else {
RETVAL_NULL();
}
if (Z_TYPE_P(value) == IS_OBJECT && instanceof_function(Z_OBJCE_P(value), php_http_message_class_entry)) {
php_http_message_object_t *parent_obj = PHP_HTTP_OBJ(NULL, value);
+ Z_ADDREF_P(value);
if (obj->message->parent) {
zend_object_release(&obj->parent->zo);
}
- Z_ADDREF_P(value);
obj->parent = parent_obj;
obj->message->parent = parent_obj->message;
}
php_http_message_object_t **objects;
int last;
- objects = ecalloc(i, sizeof(**objects));
+ objects = ecalloc(i, sizeof(*objects));
/* we are the first message */
objects[0] = obj;
case IS_RESOURCE:
php_stream_from_zval_no_verify(s, zbody);
if (!s) {
- php_http_throw(unexpected_val, "The stream is not a valid resource", NULL);
+ php_http_throw(unexpected_val, "The stream is not a valid resource");
return FAILURE;
}
return o;
}
-zend_object *php_http_message_object_clone(zval *this_ptr)
+zend_object *php_http_message_object_clone(zend_object *this_ptr)
{
- php_http_message_object_t *new_obj = NULL;
- php_http_message_object_t *old_obj = PHP_HTTP_OBJ(NULL, this_ptr);
+ php_http_message_object_t *new_obj;
+ php_http_message_object_t *old_obj = PHP_HTTP_OBJ(this_ptr, NULL);
new_obj = php_http_message_object_new_ex(old_obj->zo.ce, php_http_message_copy(old_obj->message, NULL));
zend_objects_clone_members(&new_obj->zo, &old_obj->zo);
zend_object_std_dtor(object);
}
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
+static zval *php_http_message_object_get_prop_ptr(zend_object *object, zend_string *member, int type, void **cache_slot)
{
- zval *return_value;
- zend_string *member_name = zval_get_string(member);
- php_http_message_object_prophandler_t *handler = php_http_message_object_get_prophandler(member_name);
-
- if (!handler || type == BP_VAR_R || type == BP_VAR_IS) {
- return_value = zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, tmp);
-
- if (handler) {
- php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+ return NULL;
+}
- PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
- handler->read(obj, tmp);
+static zval *php_http_message_object_read_prop(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp)
+{
+ zval *return_value;
+ php_http_message_object_prophandler_t *handler = php_http_message_object_get_prophandler(member);
- zval_ptr_dtor(return_value);
- ZVAL_COPY_VALUE(return_value, tmp);
- }
- zend_string_release(member_name);
- return return_value;
- } else {
- php_property_proxy_t *proxy;
- php_property_proxy_object_t *proxy_obj;
+ return_value = zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, tmp);
- proxy = php_property_proxy_init(object, member_name);
- proxy_obj = php_property_proxy_object_new_ex(NULL, proxy);
+ if (handler && handler->read) {
+ php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
- ZVAL_OBJ(tmp, &proxy_obj->zo);
- zend_string_release(member_name);
- return tmp;
+ handler->read(obj, return_value);
}
+ return return_value;
}
-static void php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot)
+static zval *php_http_message_object_write_prop(zend_object *object, zend_string *member, zval *value, void **cache_slot)
{
- php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+ php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
php_http_message_object_prophandler_t *handler;
- zend_string *member_name = zval_get_string(member);
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
- if ((handler = php_http_message_object_get_prophandler(member_name))) {
+ if ((handler = php_http_message_object_get_prophandler(member))) {
handler->write(obj, value);
} else {
zend_get_std_object_handlers()->write_property(object, member, value, cache_slot);
}
-
- zend_string_release(member_name);
+ return value;
}
-static HashTable *php_http_message_object_get_debug_info(zval *object, int *is_temp)
+static HashTable *php_http_message_object_get_debug_info(zend_object *object, int *is_temp)
{
zval tmp;
- php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+ php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
HashTable *props = zend_get_std_object_handlers()->get_properties(object);
char *ver_str, *url_str = NULL;
size_t ver_len, url_len = 0;
return props;
}
-static HashTable *php_http_message_object_get_gc(zval *object, zval **table, int *n)
+static HashTable *php_http_message_object_get_gc(zend_object *object, zval **table, int *n)
{
- php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
- HashTable *props = Z_OBJPROP_P(object);
+ php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
+ HashTable *props = object->handlers->get_properties(object);
uint32_t count = 2 + zend_hash_num_elements(props);
zval *val;
return NULL;
}
+static int php_http_message_object_cast(zend_object *object, zval *return_value, int type)
+{
+ php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
+ char *string;
+ size_t length;
+
+ switch (type) {
+ case IS_STRING:
+ PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
+ php_http_message_to_string(obj->message, &string, &length);
+ if (string) {
+ RETVAL_STR(php_http_cs2zs(string, length));
+ } else {
+ RETVAL_EMPTY_STRING();
+ }
+ return SUCCESS;
+ case _IS_BOOL:
+ RETVAL_TRUE;
+ return SUCCESS;
+ default:
+ return FAILURE;
+ }
+}
+
ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage___construct, 0, 0, 0)
ZEND_ARG_INFO(0, message)
ZEND_ARG_INFO(0, greedy)
php_http_buffer_init_ex(&buf, 0x1000, PHP_HTTP_BUFFER_INIT_PREALLOC);
if (PHP_HTTP_MESSAGE_PARSER_STATE_FAILURE == php_http_message_parser_parse_stream(&p, &buf, s, flags, &msg)) {
if (!EG(exception)) {
- php_http_throw(bad_message, "Could not parse message from stream", NULL);
+ php_http_throw(bad_message, "Could not parse message from stream");
}
}
php_http_buffer_dtor(&buf);
}
if (!msg && !EG(exception)) {
- php_http_throw(bad_message, "Empty message received from stream", NULL);
+ php_http_throw(bad_message, "Empty message received from stream");
}
} else if (zmessage) {
zend_string *zs_msg = zval_get_string(zmessage);
msg = php_http_message_parse(NULL, zs_msg->val, zs_msg->len, greedy);
if (!msg && !EG(exception)) {
- php_http_throw(bad_message, "Could not parse message: %.*s", MIN(25, zs_msg->len), zs_msg->val);
+ php_http_throw(bad_message, "Could not parse message: %.*s", (int) MIN(25, zs_msg->len), zs_msg->val);
}
zend_string_release(zs_msg);
}
if (!obj->body) {
php_http_message_object_init_body_object(obj);
-
}
if (obj->body) {
RETVAL_OBJECT(&obj->body->zo, 1);
RETVAL_ZVAL(getThis(), 1, 0);
}
+static inline void php_http_message_object_add_header(php_http_message_object_t *obj, const char *name_str, size_t name_len, zval *zvalue)
+{
+ char *name = php_http_pretty_key(estrndup(name_str, name_len), name_len, 1, 1);
+ zend_string *hstr, *vstr;
+ zval *header, tmp;
+
+ if (Z_TYPE_P(zvalue) == IS_NULL) {
+ return;
+ }
+
+ vstr = php_http_header_value_to_string(zvalue);
+
+ if ((name_len != lenof("Set-Cookie") && strcmp(name, "Set-Cookie"))
+ && (hstr = php_http_message_header_string(obj->message, name, name_len))) {
+ char *hdr_str;
+ size_t hdr_len = spprintf(&hdr_str, 0, "%s, %s", hstr->val, vstr->val);
+
+ ZVAL_STR(&tmp, php_http_cs2zs(hdr_str, hdr_len));
+ zend_symtable_str_update(&obj->message->hdrs, name, name_len, &tmp);
+ zend_string_release(hstr);
+ zend_string_release(vstr);
+ } else if ((header = php_http_message_header(obj->message, name, name_len))) {
+ convert_to_array(header);
+ ZVAL_STR(&tmp, vstr);
+ zend_hash_next_index_insert(Z_ARRVAL_P(header), &tmp);
+ } else {
+ ZVAL_STR(&tmp, vstr);
+ zend_symtable_str_update(&obj->message->hdrs, name, name_len, &tmp);
+ }
+ efree(name);
+}
+
ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_addHeader, 0, 0, 2)
ZEND_ARG_INFO(0, header)
ZEND_ARG_INFO(0, value)
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "sz", &name_str, &name_len, &zvalue)) {
php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
- char *name = php_http_pretty_key(estrndup(name_str, name_len), name_len, 1, 1);
- zend_string *hstr, *vstr = php_http_header_value_to_string(zvalue);
- zval tmp, *header;
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
- if ((name_len != lenof("Set-Cookie") && strcmp(name, "Set-Cookie"))
- && (hstr = php_http_message_header_string(obj->message, name, name_len))) {
- char *hdr_str;
- size_t hdr_len = spprintf(&hdr_str, 0, "%s, %s", hstr->val, vstr->val);
-
- ZVAL_STR(&tmp, php_http_cs2zs(hdr_str, hdr_len));
- zend_symtable_str_update(&obj->message->hdrs, name, name_len, &tmp);
- zend_string_release(hstr);
- zend_string_release(vstr);
- } else if ((header = php_http_message_header(obj->message, name, name_len))) {
- convert_to_array(header);
- ZVAL_STR(&tmp, vstr);
- zend_hash_next_index_insert(Z_ARRVAL_P(header), &tmp);
- } else {
- ZVAL_STR(&tmp, vstr);
- zend_symtable_str_update(&obj->message->hdrs, name, name_len, &tmp);
- }
- efree(name);
+ php_http_message_object_add_header(obj, name_str, name_len, zvalue);
}
RETVAL_ZVAL(getThis(), 1, 0);
}
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
- array_join(Z_ARRVAL_P(new_headers), &obj->message->hdrs, append, ARRAY_JOIN_STRONLY|ARRAY_JOIN_PRETTIFY);
+ if (append) {
+ php_http_arrkey_t key = {0};
+ zval *val;
+
+ ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(new_headers), key.h, key.key, val)
+ {
+ php_http_arrkey_stringify(&key, NULL);
+ php_http_message_object_add_header(obj, key.key->val, key.key->len, val);
+ php_http_arrkey_dtor(&key);
+ }
+ ZEND_HASH_FOREACH_END();
+ } else {
+ array_join(Z_ARRVAL_P(new_headers), &obj->message->hdrs, 0, ARRAY_JOIN_PRETTIFY|ARRAY_JOIN_STRONLY);
+ }
}
RETVAL_ZVAL(getThis(), 1, 0);
}
static PHP_METHOD(HttpMessage, getInfo)
{
if (SUCCESS == zend_parse_parameters_none()) {
- char *str, *tmp = NULL;
- size_t len;
+ char *str = NULL;
+ size_t len = 0;
php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
-
- switch (obj->message->type) {
- case PHP_HTTP_REQUEST:
- len = spprintf(&str, 0, PHP_HTTP_INFO_REQUEST_FMT_ARGS(&obj->message->http, tmp, ""));
- PTR_FREE(tmp);
- break;
- case PHP_HTTP_RESPONSE:
- len = spprintf(&str, 0, PHP_HTTP_INFO_RESPONSE_FMT_ARGS(&obj->message->http, tmp, ""));
- PTR_FREE(tmp);
- break;
- default:
- RETURN_NULL();
- break;
- }
+ php_http_info_to_string((php_http_info_t *) obj->message, &str, &len, "");
RETVAL_STR(php_http_cs2zs(str, len));
}
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
if (obj->message->type != PHP_HTTP_RESPONSE) {
- php_error_docref(NULL, E_WARNING, "http\\Message is not if type response");
+ php_error_docref(NULL, E_WARNING, "http\\Message is not of type response");
RETURN_FALSE;
}
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
if (obj->message->type != PHP_HTTP_RESPONSE) {
- php_http_throw(bad_method_call, "http\\Message is not of type response", NULL);
+ php_http_throw(bad_method_call, "http\\Message is not of type response");
return;
}
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
if (obj->message->type != PHP_HTTP_RESPONSE) {
- php_http_throw(bad_method_call, "http\\Message is not of type response", NULL);
+ php_http_throw(bad_method_call, "http\\Message is not of type response");
}
PTR_SET(obj->message->http.info.response.status, estrndup(status, status_len));
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
if (obj->message->type != PHP_HTTP_REQUEST) {
- php_http_throw(bad_method_call, "http\\Message is not of type request", NULL);
+ php_http_throw(bad_method_call, "http\\Message is not of type request");
return;
}
if (method_len < 1) {
- php_http_throw(invalid_arg, "Cannot set http\\Message's request method to an empty string", NULL);
+ php_http_throw(invalid_arg, "Cannot set http\\Message's request method to an empty string");
return;
}
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
if (obj->message->type != PHP_HTTP_REQUEST) {
- php_http_throw(bad_method_call, "http\\Message is not of type request", NULL);
+ php_http_throw(bad_method_call, "http\\Message is not of type request");
return;
}
zend_replace_error_handling(EH_THROW, php_http_get_exception_bad_url_class_entry(), &zeh);
- url = php_http_url_from_zval(zurl, ~0);
+ url = php_http_url_from_zval(zurl, PHP_HTTP_URL_STDFLAGS);
zend_restore_error_handling(&zeh);
if (url && php_http_url_is_empty(url)) {
php_http_url_free(&url);
- php_http_throw(invalid_arg, "Cannot set http\\Message's request url to an empty string", NULL);
+ php_http_throw(invalid_arg, "Cannot set http\\Message's request url to an empty string");
} else if (url) {
PTR_SET(obj->message->http.info.request.url, url);
}
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
if (!obj->message->parent) {
- php_http_throw(unexpected_val, "http\\Message has not parent message", NULL);
+ php_http_throw(unexpected_val, "http\\Message has no parent message");
return;
}
for (msg[0] = obj->message; msg[0]; msg[0] = msg[0]->parent) {
for (msg[1] = prepend_obj->message; msg[1]; msg[1] = msg[1]->parent) {
if (msg[0] == msg[1]) {
- php_http_throw(unexpected_val, "Cannot prepend a message located within the same message chain", NULL);
+ php_http_throw(unexpected_val, "Cannot prepend a message located within the same message chain");
return;
}
}
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
if (!php_http_message_is_multipart(obj->message, &boundary)) {
- php_http_throw(bad_method_call, "http\\Message is not a multipart message", NULL);
+ php_http_throw(bad_method_call, "http\\Message is not a multipart message");
return;
}
}
static zend_function_entry php_http_message_methods[] = {
- PHP_ME(HttpMessage, __construct, ai_HttpMessage___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+ PHP_ME(HttpMessage, __construct, ai_HttpMessage___construct, ZEND_ACC_PUBLIC)
PHP_ME(HttpMessage, getBody, ai_HttpMessage_getBody, ZEND_ACC_PUBLIC)
PHP_ME(HttpMessage, setBody, ai_HttpMessage_setBody, ZEND_ACC_PUBLIC)
PHP_ME(HttpMessage, addBody, ai_HttpMessage_addBody, ZEND_ACC_PUBLIC)
php_http_message_object_handlers.read_property = php_http_message_object_read_prop;
php_http_message_object_handlers.write_property = php_http_message_object_write_prop;
php_http_message_object_handlers.get_debug_info = php_http_message_object_get_debug_info;
+#if PHP_VERSION_ID >= 70400
+ php_http_message_object_handlers.get_property_ptr_ptr = php_http_message_object_get_prop_ptr;
+#else
php_http_message_object_handlers.get_property_ptr_ptr = NULL;
+#endif
php_http_message_object_handlers.get_gc = php_http_message_object_get_gc;
+ php_http_message_object_handlers.cast_object = php_http_message_object_cast;
zend_class_implements(php_http_message_class_entry, 3, spl_ce_Countable, zend_ce_serializable, zend_ce_iterator);