char *tmp = NULL;
size_t len = 0;
- php_http_info_to_string((php_http_info_t *) msg, &tmp, &len, PHP_HTTP_CRLF TSRMLS_CC);
+ 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);
}
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 PHP_WRITE_PROP_HANDLER_TYPE php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot);
static zend_object_handlers php_http_message_object_handlers;
static HashTable php_http_message_object_prophandlers;
}
}
static void php_http_message_object_prophandler_get_body(php_http_message_object_t *obj, zval *return_value) {
- if (obj->body) {
- zval tmp;
+ zval tmp;
- ZVAL_COPY_VALUE(&tmp, return_value);
- RETVAL_OBJECT(&obj->body->zo, 1);
- zval_ptr_dtor(&tmp);
- } else {
- RETVAL_NULL();
+ if (!obj->body) {
+ RETURN_NULL();
}
+
+ ZVAL_COPY_VALUE(&tmp, return_value);
+ RETVAL_OBJECT(&obj->body->zo, 1);
+ zval_ptr_dtor(&tmp);
}
static void php_http_message_object_prophandler_set_body(php_http_message_object_t *obj, zval *value) {
php_http_message_object_set_body(obj, value);
do { \
if (!obj->message) { \
obj->message = php_http_message_init(NULL, 0, NULL); \
+ } else if (!obj->body && php_http_message_body_size(obj->message->body)) { \
+ php_http_message_object_init_body_object(obj); \
} \
} while(0)
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;
}
zend_object_std_dtor(object);
}
+#if PHP_VERSION_ID >= 70400
+static zval *php_http_message_object_get_prop_ptr(zval *object, zval *member, int type, void **cache_slot)
+{
+ return NULL;
+}
+#endif
+
static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
{
zval *return_value;
return return_value;
}
-static void php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot)
+static PHP_WRITE_PROP_HANDLER_TYPE php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot)
{
php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
php_http_message_object_prophandler_t *handler;
}
zend_string_release(member_name);
+ PHP_WRITE_PROP_HANDLER_RETURN(value);
}
static HashTable *php_http_message_object_get_debug_info(zval *object, int *is_temp)
size_t ver_len, url_len = 0;
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
- *is_temp = 0;
+ if (is_temp) {
+ *is_temp = 0;
+ }
#define UPDATE_PROP(name_str, action_with_tmp) \
do { \
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);
}
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;
}
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;
}
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;
zend_class_implements(php_http_message_class_entry, 3, spl_ce_Countable, zend_ce_serializable, zend_ce_iterator);