- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &string, &length, &class_name, &class_length)) {
- if ((msg = http_message_parse(string, length))) {
- zend_class_entry *ce = http_message_object_ce;
-
- if (class_name && *class_name) {
- ce = zend_fetch_class(class_name, class_length, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC);
- if (ce && !instanceof_function(ce, http_message_object_ce TSRMLS_CC)) {
- http_error_ex(HE_WARNING, HTTP_E_RUNTIME, "Class %s does not extend HttpMessage", class_name);
- ce = NULL;
- }
- }
- if (ce) {
- RETVAL_OBJVAL(http_message_object_new_ex(ce, msg, NULL), 0);
- }
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ss", &string, &length, &cn, &cl)) {
+ if (length) {
+ msg = http_message_parse(string, length);
+ }
+ if ((msg || !length) && SUCCESS == http_object_new(&ov, cn, cl, _http_message_object_new_ex, http_message_object_ce, msg, &obj)) {
+ RETVAL_OBJVAL(ov, 0);
+ }
+ if (obj && !obj->message) {
+ obj->message = http_message_new();