- INIT_PZVAL(&body);
- ZVAL_STRINGL(&body, PHPSTR_VAL(obj->message), PHPSTR_LEN(obj->message), 0);
- zend_call_method_with_1_params(&return_value, http_request_object_ce, NULL, "setrawpostdata", NULL, &body);
+ if (PHPSTR_VAL(obj->message) && PHPSTR_LEN(obj->message)) {
+ INIT_PZVAL(&body);
+ ZVAL_STRINGL(&body, PHPSTR_VAL(obj->message), PHPSTR_LEN(obj->message), 0);
+ if (method != HTTP_POST) {
+ zend_call_method_with_1_params(&return_value, http_request_object_ce, NULL, "setbody", NULL, &body);
+ } else {
+ INIT_PZVAL(&post);
+ array_init(&post);
+
+ zval_copy_ctor(&body);
+ sapi_module.treat_data(PARSE_STRING, Z_STRVAL(body), &post TSRMLS_CC);
+ zend_call_method_with_1_params(&return_value, http_request_object_ce, NULL, "setpostfields", NULL, &post);
+ }
+ }