switch (type) {
case PHP_HTTP_REQUEST:
- mbody = php_http_env_get_request_body(TSRMLS_C);
+ mbody = php_http_env_get_request_body();
php_http_message_body_addref(mbody);
- message = php_http_message_init(message, type, mbody TSRMLS_CC);
- if ((sval = php_http_env_get_server_var(ZEND_STRL("SERVER_PROTOCOL"), 1 TSRMLS_CC)) && !strncmp(Z_STRVAL_P(sval), "HTTP/", lenof("HTTP/"))) {
- php_http_version_parse(&message->http.version, Z_STRVAL_P(sval) TSRMLS_CC);
+ message = php_http_message_init(message, type, mbody);
+ if ((sval = php_http_env_get_server_var(ZEND_STRL("SERVER_PROTOCOL"), 1)) && !strncmp(Z_STRVAL_P(sval), "HTTP/", lenof("HTTP/"))) {
+ php_http_version_parse(&message->http.version, Z_STRVAL_P(sval));
}
- if ((sval = php_http_env_get_server_var(ZEND_STRL("REQUEST_METHOD"), 1 TSRMLS_CC))) {
+ if ((sval = php_http_env_get_server_var(ZEND_STRL("REQUEST_METHOD"), 1))) {
message->http.info.request.method = estrdup(Z_STRVAL_P(sval));
}
- if ((sval = php_http_env_get_server_var(ZEND_STRL("REQUEST_URI"), 1 TSRMLS_CC))) {
- message->http.info.request.url = php_http_url_parse(Z_STRVAL_P(sval), Z_STRLEN_P(sval), ~0 TSRMLS_CC);
+ if ((sval = php_http_env_get_server_var(ZEND_STRL("REQUEST_URI"), 1))) {
+ message->http.info.request.url = php_http_url_parse(Z_STRVAL_P(sval), Z_STRLEN_P(sval), ~0);
}
- php_http_env_get_request_headers(&message->hdrs TSRMLS_CC);
+
+ php_http_env_get_request_headers(&message->hdrs);
break;
case PHP_HTTP_RESPONSE:
}
message->http.info.response.status = estrdup(php_http_env_get_response_status_for_code(message->http.info.response.code));
}
-
+
- php_http_env_get_response_headers(&message->hdrs TSRMLS_CC);
-#if PHP_VERSION_ID >= 50400
- if (php_output_get_level(TSRMLS_C)) {
- if (php_output_get_status(TSRMLS_C) & PHP_OUTPUT_SENT) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(TSRMLS_C), php_output_get_start_lineno(TSRMLS_C));
- goto error;
- } else if (SUCCESS != php_output_get_contents(&tval TSRMLS_CC)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch response body");
- goto error;
- } else {
- php_http_message_body_append(message->body, Z_STRVAL(tval), Z_STRLEN(tval));
- zval_dtor(&tval);
- }
- }
-#else
- if (OG(ob_nesting_level)) {
- if (php_get_output_start_filename(TSRMLS_C)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_get_output_start_filename(TSRMLS_C), php_get_output_start_lineno(TSRMLS_C));
+ php_http_env_get_response_headers(&message->hdrs);
+ if (php_output_get_level()) {
+ if (php_output_get_status() & PHP_OUTPUT_SENT) {
+ php_error_docref(NULL, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(), php_output_get_start_lineno());
++
goto error;
- } else if (SUCCESS != php_ob_get_buffer(&tval TSRMLS_CC)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch response body");
+ } else if (SUCCESS != php_output_get_contents(&tval)) {
+ php_error_docref(NULL, E_WARNING, "Could not fetch response body");
goto error;
} else {
php_http_message_body_append(message->body, Z_STRVAL(tval), Z_STRLEN(tval));
php_http_message_t *php_http_message_reverse(php_http_message_t *msg)
{
- int i, c = 0;
-
- php_http_message_count(c, msg);
+ size_t i, c = php_http_message_count(msg);
-
+
if (c > 1) {
php_http_message_t *tmp = msg, **arr;
{
php_http_message_t *temp, *copy = NULL;
php_http_info_t info;
-
- TSRMLS_FETCH_FROM_CTX(from->ts);
+
if (from) {
info.type = from->type;
info.http = from->http;
-
+
- copy = temp = php_http_message_init(to, 0, php_http_message_body_copy(from->body, NULL) TSRMLS_CC);
+ copy = temp = php_http_message_init(to, 0, php_http_message_body_copy(from->body, NULL));
php_http_message_set_info(temp, &info);
- zend_hash_copy(&temp->hdrs, &from->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+ zend_hash_copy(&temp->hdrs, &from->hdrs, (copy_ctor_func_t) zval_add_ref);
-
+
if (parents) while (from->parent) {
info.type = from->parent->type;
info.http = from->parent->http;
-
+
- temp->parent = php_http_message_init(NULL, 0, php_http_message_body_copy(from->parent->body, NULL) TSRMLS_CC);
+ temp->parent = php_http_message_init(NULL, 0, php_http_message_body_copy(from->parent->body, NULL));
php_http_message_set_info(temp->parent, &info);
- zend_hash_copy(&temp->parent->hdrs, &from->parent->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+ array_copy(&from->parent->hdrs, &temp->parent->hdrs);
-
temp = temp->parent;
from = from->parent;
size_t ver_len, url_len = 0;
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
- INIT_PZVAL_ARRAY(&array, props);
+ *is_temp = 0;
-
+
-#define ASSOC_PROP(ptype, n, val) \
+#define UPDATE_PROP(name_str, action_with_tmp) \
do { \
zend_property_info *pi; \
- if (SUCCESS == zend_hash_find(&obj->zo.ce->properties_info, n, sizeof(n), (void *) &pi)) { \
- add_assoc_ ##ptype## _ex(&array, pi->name, pi->name_length + 1, val); \
- } \
- } while(0) \
-
-#define ASSOC_STRING(name, val) ASSOC_STRINGL(name, val, strlen(val))
-#define ASSOC_STRINGL(name, val, len) ASSOC_STRINGL_EX(name, val, len, 1)
-#define ASSOC_STRINGL_EX(n, val, len, cpy) \
- do { \
- zend_property_info *pi; \
- if (SUCCESS == zend_hash_find(&obj->zo.ce->properties_info, n, sizeof(n), (void *) &pi)) { \
- add_assoc_stringl_ex(&array, pi->name, pi->name_length + 1, val, len, cpy); \
+ if ((pi = zend_hash_str_find_ptr(&obj->zo.ce->properties_info, name_str, lenof(name_str)))) { \
+ action_with_tmp; \
+ zend_hash_update_ind(props, pi->name, &tmp); \
} \
} while(0)