X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_client_request.c;h=db8ef51f318fed893de7a88ca4ff34375fef25ff;hb=03950c1eaf949eb56a9cf27655ffbb9ac88e0298;hp=86843e6428b8d6199b50450b2e79de24db29df7c;hpb=847c94ac2eef3c43200a7e066a7ee823d580b20c;p=m6w6%2Fext-http diff --git a/php_http_client_request.c b/php_http_client_request.c index 86843e6..db8ef51 100644 --- a/php_http_client_request.c +++ b/php_http_client_request.c @@ -31,22 +31,16 @@ static PHP_METHOD(HttpClientRequest, __construct) with_error_handling(EH_THROW, php_http_exception_class_entry) { if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!a!O!", &meth_str, &meth_len, &url_str, &url_len, &zheaders, &zbody, php_http_message_body_class_entry)) { php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); - php_http_message_body_object_t *body_obj = NULL; - - if (zbody) { - php_http_message_object_set_body(obj, zbody TSRMLS_CC); - } if (obj->message) { php_http_message_set_type(obj->message, PHP_HTTP_REQUEST); - if (body_obj) { - php_http_message_body_free(&obj->message->body); - obj->message->body = body_obj->body; - } } else { - obj->message = php_http_message_init(NULL, PHP_HTTP_REQUEST, body_obj ? body_obj->body : NULL TSRMLS_CC); + obj->message = php_http_message_init(NULL, PHP_HTTP_REQUEST, NULL TSRMLS_CC); } + if (zbody) { + php_http_message_object_set_body(obj, zbody TSRMLS_CC); + } if (meth_str && meth_len) { PHP_HTTP_INFO(obj->message).request.method = estrndup(meth_str, meth_len); } @@ -93,11 +87,14 @@ static PHP_METHOD(HttpClientRequest, getContentType) { if (SUCCESS == zend_parse_parameters_none()) { php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); - zval *zct = php_http_message_header(obj->message, ZEND_STRL("Content-Type"), 1); + zval *zct; - RETURN_ZVAL(zct, 0, 1); + php_http_message_update_headers(obj->message); + zct = php_http_message_header(obj->message, ZEND_STRL("Content-Type"), 1); + if (zct) { + RETURN_ZVAL(zct, 0, 1); + } } - RETURN_FALSE; } ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_setQuery, 0, 0, 0)