- http_message *save_parent_msg;
- zend_object_value save_parent_obj;
+ http_message *save_parent_msg = NULL;
+ zend_object_value save_parent_obj = {0, NULL};
getObject(http_message_object, obj);
getObjectEx(http_message_object, prepend_obj, prepend);
getObject(http_message_object, obj);
getObjectEx(http_message_object, prepend_obj, prepend);
case HTTP_MSG_PROPHASH_HTTP_VERSION:
case HTTP_MSG_CHILD_PROPHASH_HTTP_VERSION:
RETVAL_DOUBLE(msg->http.version);
case HTTP_MSG_PROPHASH_HTTP_VERSION:
case HTTP_MSG_CHILD_PROPHASH_HTTP_VERSION:
RETVAL_DOUBLE(msg->http.version);
case HTTP_MSG_PROPHASH_BODY:
case HTTP_MSG_CHILD_PROPHASH_BODY:
phpstr_fix(PHPSTR(msg));
RETVAL_PHPSTR(PHPSTR(msg), 0, 1);
case HTTP_MSG_PROPHASH_BODY:
case HTTP_MSG_CHILD_PROPHASH_BODY:
phpstr_fix(PHPSTR(msg));
RETVAL_PHPSTR(PHPSTR(msg), 0, 1);
case HTTP_MSG_PROPHASH_HEADERS:
case HTTP_MSG_CHILD_PROPHASH_HEADERS:
array_init(return_value);
zend_hash_copy(Z_ARRVAL_P(return_value), &msg->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
case HTTP_MSG_PROPHASH_HEADERS:
case HTTP_MSG_CHILD_PROPHASH_HEADERS:
array_init(return_value);
zend_hash_copy(Z_ARRVAL_P(return_value), &msg->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
case HTTP_MSG_CHILD_PROPHASH_TYPE:
convert_to_long(cpy);
http_message_set_type(msg, Z_LVAL_P(cpy));
case HTTP_MSG_CHILD_PROPHASH_TYPE:
convert_to_long(cpy);
http_message_set_type(msg, Z_LVAL_P(cpy));
case HTTP_MSG_PROPHASH_HTTP_VERSION:
case HTTP_MSG_CHILD_PROPHASH_HTTP_VERSION:
convert_to_double(cpy);
msg->http.version = Z_DVAL_P(cpy);
case HTTP_MSG_PROPHASH_HTTP_VERSION:
case HTTP_MSG_CHILD_PROPHASH_HTTP_VERSION:
convert_to_double(cpy);
msg->http.version = Z_DVAL_P(cpy);
case HTTP_MSG_PROPHASH_BODY:
case HTTP_MSG_CHILD_PROPHASH_BODY:
convert_to_string(cpy);
phpstr_dtor(PHPSTR(msg));
phpstr_from_string_ex(PHPSTR(msg), Z_STRVAL_P(cpy), Z_STRLEN_P(cpy));
case HTTP_MSG_PROPHASH_BODY:
case HTTP_MSG_CHILD_PROPHASH_BODY:
convert_to_string(cpy);
phpstr_dtor(PHPSTR(msg));
phpstr_from_string_ex(PHPSTR(msg), Z_STRVAL_P(cpy), Z_STRLEN_P(cpy));
case HTTP_MSG_PROPHASH_HEADERS:
case HTTP_MSG_CHILD_PROPHASH_HEADERS:
convert_to_array(cpy);
zend_hash_clean(&msg->hdrs);
zend_hash_copy(&msg->hdrs, Z_ARRVAL_P(cpy), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
case HTTP_MSG_PROPHASH_HEADERS:
case HTTP_MSG_CHILD_PROPHASH_HEADERS:
convert_to_array(cpy);
zend_hash_clean(&msg->hdrs);
zend_hash_copy(&msg->hdrs, Z_ARRVAL_P(cpy), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
getObjectEx(http_message_object, obj, object);
http_message *msg = obj->message;
HashTable *props = OBJ_PROP(obj);
getObjectEx(http_message_object, obj, object);
http_message *msg = obj->message;
HashTable *props = OBJ_PROP(obj);
ASSOC_PROP(array, long, "type", msg->type);
ASSOC_PROP(array, double, "httpVersion", msg->http.version);
ASSOC_PROP(array, long, "type", msg->type);
ASSOC_PROP(array, double, "httpVersion", msg->http.version);
case HTTP_MSG_REQUEST:
ASSOC_PROP(array, long, "responseCode", 0);
ASSOC_STRINGL(array, "responseStatus", "", 0);
ASSOC_STRING(array, "requestMethod", msg->http.info.request.method);
ASSOC_STRING(array, "requestUrl", msg->http.info.request.url);
case HTTP_MSG_REQUEST:
ASSOC_PROP(array, long, "responseCode", 0);
ASSOC_STRINGL(array, "responseStatus", "", 0);
ASSOC_STRING(array, "requestMethod", msg->http.info.request.method);
ASSOC_STRING(array, "requestUrl", msg->http.info.request.url);
case HTTP_MSG_RESPONSE:
ASSOC_PROP(array, long, "responseCode", msg->http.info.response.code);
ASSOC_STRING(array, "responseStatus", msg->http.info.response.status);
ASSOC_STRINGL(array, "requestMethod", "", 0);
ASSOC_STRINGL(array, "requestUrl", "", 0);
case HTTP_MSG_RESPONSE:
ASSOC_PROP(array, long, "responseCode", msg->http.info.response.code);
ASSOC_STRING(array, "responseStatus", msg->http.info.response.status);
ASSOC_STRINGL(array, "requestMethod", "", 0);
ASSOC_STRINGL(array, "requestUrl", "", 0);
ASSOC_STRINGL(array, "responseStatus", "", 0);
ASSOC_STRINGL(array, "requestMethod", "", 0);
ASSOC_STRINGL(array, "requestUrl", "", 0);
ASSOC_STRINGL(array, "responseStatus", "", 0);
ASSOC_STRINGL(array, "requestMethod", "", 0);
ASSOC_STRINGL(array, "requestUrl", "", 0);
zend_hash_copy(Z_ARRVAL_P(headers), &msg->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
ASSOC_PROP(array, zval, "headers", headers);
ASSOC_STRINGL(array, "body", PHPSTR_VAL(msg), PHPSTR_LEN(msg));
zend_hash_copy(Z_ARRVAL_P(headers), &msg->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
ASSOC_PROP(array, zval, "headers", headers);
ASSOC_STRINGL(array, "body", PHPSTR_VAL(msg), PHPSTR_LEN(msg));
getObject(http_message_object, obj);
RETURN_PHPSTR(&obj->message->body, PHPSTR_FREE_NOT, 1);
}
getObject(http_message_object, obj);
RETURN_PHPSTR(&obj->message->body, PHPSTR_FREE_NOT, 1);
}
getObject(http_message_object, obj);
RETURN_LONG(obj->message->type);
}
getObject(http_message_object, obj);
RETURN_LONG(obj->message->type);
}
getObject(http_message_object, obj);
HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj->message, RETURN_FALSE);
RETURN_LONG(obj->message->http.info.response.code);
getObject(http_message_object, obj);
HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj->message, RETURN_FALSE);
RETURN_LONG(obj->message->http.info.response.code);
getObject(http_message_object, obj);
HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj->message, RETURN_FALSE);
RETURN_STRING(obj->message->http.info.response.status, 1);
getObject(http_message_object, obj);
HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj->message, RETURN_FALSE);
RETURN_STRING(obj->message->http.info.response.status, 1);
getObject(http_message_object, obj);
HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE);
RETURN_STRING(obj->message->http.info.request.method, 1);
getObject(http_message_object, obj);
HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE);
RETURN_STRING(obj->message->http.info.request.method, 1);
http_error(HE_WARNING, HTTP_E_INVALID_PARAM, "Cannot set HttpMessage::requestMethod to an empty string");
RETURN_FALSE;
}
http_error(HE_WARNING, HTTP_E_INVALID_PARAM, "Cannot set HttpMessage::requestMethod to an empty string");
RETURN_FALSE;
}
- if (SUCCESS != http_check_method(method)) {
- http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Unkown request method: %s", method);
+ if (!http_request_method_exists(1, 0, method)) {
+ http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Unknown request method: %s", method);
getObject(http_message_object, obj);
HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE);
RETURN_STRING(obj->message->http.info.request.url, 1);
getObject(http_message_object, obj);
HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE);
RETURN_STRING(obj->message->http.info.request.url, 1);
getObject(http_message_object, obj);
if (obj->message->parent) {
RETVAL_OBJVAL(obj->parent, 1);
} else {
getObject(http_message_object, obj);
if (obj->message->parent) {
RETVAL_OBJVAL(obj->parent, 1);
} else {
#else
http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot transform HttpMessage to HttpRequest (missing curl support)");
#endif
#else
http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot transform HttpMessage to HttpRequest (missing curl support)");
#endif
INIT_PZVAL(&zkey);
ZVAL_STRINGL(&zkey, key, key_len, 0);
INIT_PZVAL(&zkey);
ZVAL_STRINGL(&zkey, key, key_len, 0);
zend_call_method_with_2_params(&return_value, http_response_object_ce, NULL, "setheader", NULL, &zkey, *h);
zval_ptr_dtor(h);
}
zend_call_method_with_2_params(&return_value, http_response_object_ce, NULL, "setheader", NULL, &zkey, *h);
zval_ptr_dtor(h);
}
default:
ZVAL_ADDREF(*header);
zend_call_method_with_2_params(&return_value, http_response_object_ce, NULL, "setheader", NULL, &zkey, *header);
zval_ptr_dtor(header);
default:
ZVAL_ADDREF(*header);
zend_call_method_with_2_params(&return_value, http_response_object_ce, NULL, "setheader", NULL, &zkey, *header);
zval_ptr_dtor(header);
#else
http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot transform HttpMessage to HttpResponse (need PHP 5.1+)");
#endif
#else
http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot transform HttpMessage to HttpResponse (need PHP 5.1+)");
#endif
default:
http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is neither of type HttpMessage::TYPE_REQUEST nor HttpMessage::TYPE_RESPONSE");
default:
http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is neither of type HttpMessage::TYPE_REQUEST nor HttpMessage::TYPE_RESPONSE");
zend_bool top = 1;
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &prepend, http_message_object_ce, &top)) {
zend_bool top = 1;
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &prepend, http_message_object_ce, &top)) {
+ http_message *msg[2];
+ getObject(http_message_object, obj);
+ getObjectEx(http_message_object, prepend_obj, prepend);
+
+ /* safety check */
+ for (msg[0] = obj->message; msg[0]; msg[0] = msg[0]->parent) {
+ for (msg[1] = prepend_obj->message; msg[1]; msg[1] = msg[1]->parent) {
+ if (msg[0] == msg[1]) {
+ http_error(HE_THROW, HTTP_E_INVALID_PARAM, "Cannot prepend a message located within the same message chain");
+ return;
+ }
+ }
+ }
+