HTTP_ARG_VAL(name, 0)
HTTP_END_ARGS;
+HTTP_EMPTY_ARGS(getMessageClass);
+HTTP_BEGIN_ARGS(setMessageClass, 1)
+ HTTP_ARG_VAL(message_class_name, 0)
+HTTP_END_ARGS;
+
HTTP_EMPTY_ARGS(getResponseMessage);
HTTP_EMPTY_ARGS(getRawResponseMessage);
HTTP_EMPTY_ARGS(getRequestMessage);
HTTP_REQUEST_ME(getHistory, ZEND_ACC_PUBLIC)
HTTP_REQUEST_ME(clearHistory, ZEND_ACC_PUBLIC)
+ HTTP_REQUEST_ME(getMessageClass, ZEND_ACC_PUBLIC)
+ HTTP_REQUEST_ME(setMessageClass, ZEND_ACC_PUBLIC)
+
HTTP_REQUEST_ME(factory, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
HTTP_REQUEST_ALIAS(get, http_get)
zend_declare_property_string(THIS_CE, ZEND_STRS("putData")-1, "", ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(THIS_CE, ZEND_STRS("history")-1, ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_bool(THIS_CE, ZEND_STRS("recordHistory")-1, 0, ZEND_ACC_PUBLIC TSRMLS_CC);
+ zend_declare_property_string(THIS_CE, ZEND_STRS("messageClass")-1, "", ZEND_ACC_PRIVATE TSRMLS_CC);
#ifndef WONKY
/*
}
}
+#define http_request_object_message(zo, msg) _http_request_object_message((zo), (msg) TSRMLS_CC)
+static inline zend_object_value _http_request_object_message(zval *this_ptr, http_message *msg TSRMLS_DC)
+{
+ zend_object_value ov;
+ zval *zcn = zend_read_property(THIS_CE, getThis(), ZEND_STRS("messageClass")-1, 0 TSRMLS_CC);
+
+ if (Z_STRLEN_P(zcn) && (SUCCESS == http_object_new(&ov, Z_STRVAL_P(zcn), Z_STRLEN_P(zcn), _http_message_object_new_ex, http_message_object_ce, msg, NULL))) {
+ return ov;
+ } else {
+ return http_message_object_new_ex(http_message_object_ce, msg, NULL);
+ }
+}
+
STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ptr TSRMLS_DC)
{
STATUS status = SUCCESS;
http_message *request = http_message_parse(PHPSTR_VAL(&obj->request->conv.request), PHPSTR_LEN(&obj->request->conv.request));
MAKE_STD_ZVAL(hist);
- ZVAL_OBJVAL(hist, http_message_object_new_ex(http_message_object_ce, http_message_interconnect(response, request), NULL), 0);
+ ZVAL_OBJVAL(hist, http_request_object_message(getThis(), http_message_interconnect(response, request)), 0);
if (Z_TYPE_P(history) == IS_OBJECT) {
http_message_object_prepend(hist, history);
}
zend_update_property_string(THIS_CE, getThis(), ZEND_STRS("responseStatus")-1, STR_PTR(msg->http.info.response.status) TSRMLS_CC);
MAKE_STD_ZVAL(message);
- ZVAL_OBJVAL(message, http_message_object_new_ex(http_message_object_ce, msg, NULL), 0);
+ ZVAL_OBJVAL(message, http_request_object_message(getThis(), msg), 0);
zend_update_property(THIS_CE, getThis(), ZEND_STRS("responseMessage")-1, message TSRMLS_CC);
zval_ptr_dtor(&message);
zval *hist, *history = zend_read_property(THIS_CE, getThis(), ZEND_STRS("history")-1, 0 TSRMLS_CC);
MAKE_STD_ZVAL(hist);
- ZVAL_OBJVAL(hist, http_message_object_new_ex(http_message_object_ce, request, NULL), 0);
+ ZVAL_OBJVAL(hist, http_request_object_message(getThis(), request), 0);
if (Z_TYPE_P(history) == IS_OBJECT) {
http_message_object_prepend(hist, history);
}
http_request_enable_cookies(obj->request);
} else if (KEYMATCH(key, "recordHistory")) {
zend_update_property(THIS_CE, getThis(), ZEND_STRS("recordHistory")-1, *opt TSRMLS_CC);
+ } else if (KEYMATCH(key, "messageClass")) {
+ zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "setmessageclass", NULL, *opt);
} else if (Z_TYPE_PP(opt) == IS_NULL) {
old_opts = zend_read_property(THIS_CE, getThis(), ZEND_STRS("options")-1, 0 TSRMLS_CC);
if (Z_TYPE_P(old_opts) == IS_ARRAY) {
SET_EH_THROW_HTTP();
if ((msg = http_message_parse(PHPSTR_VAL(&obj->request->conv.request), PHPSTR_LEN(&obj->request->conv.request)))) {
- RETVAL_OBJVAL(http_message_object_new_ex(http_message_object_ce, msg, NULL), 0);
+ RETVAL_OBJVAL(http_request_object_message(getThis(), msg), 0);
}
SET_EH_NORMAL();
}
}
/* }}} */
+/* {{{ proto string HttpRequest::getMessageClass()
+ Get the message class name. */
+PHP_METHOD(HttpRequest, getMessageClass)
+{
+ NO_ARGS;
+
+ if (return_value_used) {
+ RETURN_PROP("messageClass");
+ }
+}
+/* }}} */
+
+/* {{{ proto void setMessageClass(string class_name)
+ Set the message class name. */
+PHP_METHOD(HttpRequest, setMessageClass)
+{
+ char *cn;
+ int cl;
+
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &cn, &cl)) {
+ zend_update_property_stringl(THIS_CE, getThis(), ZEND_STRS("messageClass")-1, cn, cl TSRMLS_CC);
+ }
+}
+/* }}} */
+
/* {{{ proto HttpMessage HttpRequest::send()
Send the HTTP request. */
PHP_METHOD(HttpRequest, send)