#ifdef HTTP_HAVE_CURL
char *uri = NULL;
http_request request;
- zval **zhost, options, headers;
-
- INIT_PZVAL(&options);
- INIT_PZVAL(&headers);
- array_init(&options);
- array_init(&headers);
- zend_hash_copy(Z_ARRVAL(headers), &message->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
- add_assoc_zval(&options, "headers", &headers);
+ zval **zhost, *options, *headers;
+
+ MAKE_STD_ZVAL(options);
+ MAKE_STD_ZVAL(headers);
+ array_init(options);
+ array_init(headers);
+ zend_hash_copy(Z_ARRVAL_P(headers), &message->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+ add_assoc_zval(options, "headers", headers);
/* check host header */
- if (SUCCESS == zend_hash_find(&message->hdrs, "Host", sizeof("Host"), (void *) &zhost)) {
+ if (SUCCESS == zend_hash_find(&message->hdrs, "Host", sizeof("Host"), (void *) &zhost) && Z_TYPE_PP(zhost) == IS_STRING) {
char *colon = NULL;
php_url parts, *url = php_url_parse(message->http.info.request.url);
http_request_init_ex(&request, NULL, request.meth, uri);
request.body = http_request_body_init_ex(&body, HTTP_REQUEST_BODY_CSTRING, PHPSTR_VAL(message), PHPSTR_LEN(message), 0);
- if (SUCCESS == (rs = http_request_prepare(&request, NULL))) {
+ if (SUCCESS == (rs = http_request_prepare(&request, Z_ARRVAL_P(options)))) {
http_request_exec(&request);
}
http_request_dtor(&request);
message->http.info.request.method);
}
efree(uri);
+ zval_ptr_dtor(&options);
#else
http_error(HE_WARNING, HTTP_E_RUNTIME, "HTTP requests not supported - ext/http was not linked against libcurl.");
#endif
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &body, &len)) {
phpstr_dtor(PHPSTR(obj->message));
phpstr_from_string_ex(PHPSTR(obj->message), body, len);
- phpstr_fix(PHPSTR(obj->message));
}
}
/* }}} */
zval_ptr_dtor(&array);
if (PHPSTR_VAL(obj->message) && PHPSTR_LEN(obj->message)) {
+ phpstr_fix(PHPSTR(obj->message));
INIT_PZVAL(&body);
ZVAL_STRINGL(&body, PHPSTR_VAL(obj->message), PHPSTR_LEN(obj->message), 0);
if (method != HTTP_POST) {