X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_message_object.c;h=c984e960fa00a34e2da1a78f282c55784d1e8443;hb=2c0c193bdcfaa2e3c6b336da078f371e96fcec52;hp=1a5980e18b92c690576032474b0d92debe397d7e;hpb=c8dff7011092296f9fcc12e68ad8eef18b19cdf4;p=m6w6%2Fext-http diff --git a/http_message_object.c b/http_message_object.c index 1a5980e..c984e96 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -350,7 +350,8 @@ zend_object_value _http_message_object_new_ex(zend_class_entry *ce, http_message } ALLOC_HASHTABLE(OBJ_PROP(o)); - zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), 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 = putObject(http_message_object, o); ov.handlers = &http_message_object_handlers; @@ -360,8 +361,14 @@ zend_object_value _http_message_object_new_ex(zend_class_entry *ce, http_message zend_object_value _http_message_object_clone_obj(zval *this_ptr TSRMLS_DC) { - getObject(http_message_object, obj); - return http_message_object_new_ex(Z_OBJCE_P(this_ptr), http_message_dup(obj->message), NULL); + zend_object_value new_ov; + http_message_object *new_obj = NULL; + getObject(http_message_object, old_obj); + + new_ov = http_message_object_new_ex(old_obj->zo.ce, http_message_dup(old_obj->message), &new_obj); + zend_objects_clone_members(&new_obj->zo, new_ov, &old_obj->zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC); + + return new_ov; } void _http_message_object_free(zend_object *object TSRMLS_DC) @@ -630,13 +637,13 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC) case HTTP_MSG_REQUEST: ASSOC_PROP(array, long, "responseCode", 0); ASSOC_STRINGL(array, "responseStatus", "", 0); - ASSOC_STRING(array, "requestMethod", msg->http.info.request.method); - ASSOC_STRING(array, "requestUrl", msg->http.info.request.url); + ASSOC_STRING(array, "requestMethod", msg->http.info.request.method?msg->http.info.request.method:""); + ASSOC_STRING(array, "requestUrl", msg->http.info.request.url?msg->http.info.request.url:""); break; case HTTP_MSG_RESPONSE: ASSOC_PROP(array, long, "responseCode", msg->http.info.response.code); - ASSOC_STRING(array, "responseStatus", msg->http.info.response.status); + ASSOC_STRING(array, "responseStatus", msg->http.info.response.status?msg->http.info.response.status:""); ASSOC_STRINGL(array, "requestMethod", "", 0); ASSOC_STRINGL(array, "requestUrl", "", 0); break;