projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
- fix bug #6645: doesn't compile with zlib 1.2.2 (undefined Z_FIXED)
[m6w6/ext-http]
/
http_request_object.c
diff --git
a/http_request_object.c
b/http_request_object.c
index 6307539058e7c76879d78104b3b85dfe0f987994..e6ed74ae0aaafd0dd2e876e746296e8322bdc08e 100644
(file)
--- a/
http_request_object.c
+++ b/
http_request_object.c
@@
-6,16
+6,12
@@
| modification, are permitted provided that the conditions mentioned |
| in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
| modification, are permitted provided that the conditions mentioned |
| in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
- | Copyright (c) 2004-200
5
, Michael Wallner <mike@php.net> |
+ | Copyright (c) 2004-200
6
, Michael Wallner <mike@php.net> |
+--------------------------------------------------------------------+
*/
/* $Id$ */
+--------------------------------------------------------------------+
*/
/* $Id$ */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#define HTTP_WANT_CURL
#include "php_http.h"
#define HTTP_WANT_CURL
#include "php_http.h"
@@
-302,7
+298,7
@@
PHP_MINIT_FUNCTION(http_request_object)
zend_object_value _http_request_object_new(zend_class_entry *ce TSRMLS_DC)
{
zend_object_value _http_request_object_new(zend_class_entry *ce TSRMLS_DC)
{
- return http_request_object_new_ex(ce,
curl_easy_init()
, NULL);
+ return http_request_object_new_ex(ce,
NULL
, NULL);
}
zend_object_value _http_request_object_new_ex(zend_class_entry *ce, CURL *ch, http_request_object **ptr TSRMLS_DC)
}
zend_object_value _http_request_object_new_ex(zend_class_entry *ce, CURL *ch, http_request_object **ptr TSRMLS_DC)
@@
-337,7
+333,10
@@
zend_object_value _http_request_object_clone_obj(zval *this_ptr TSRMLS_DC)
getObject(http_request_object, old_obj);
old_zo = zend_objects_get_address(this_ptr TSRMLS_CC);
getObject(http_request_object, old_obj);
old_zo = zend_objects_get_address(this_ptr TSRMLS_CC);
- new_ov = http_request_object_new_ex(old_zo->ce, curl_easy_duphandle(old_obj->request->ch), &new_obj);
+ new_ov = http_request_object_new_ex(old_zo->ce, NULL, &new_obj);
+ if (old_obj->request->ch) {
+ http_curl_init_ex(curl_easy_duphandle(old_obj->request->ch), new_obj->request);
+ }
zend_objects_clone_members(&new_obj->zo, new_ov, old_zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
phpstr_append(&new_obj->history, old_obj->history.data, old_obj->history.used);
zend_objects_clone_members(&new_obj->zo, new_ov, old_zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
phpstr_append(&new_obj->history, old_obj->history.data, old_obj->history.used);
@@
-403,6
+402,11
@@
static inline void _http_request_object_declare_default_properties(TSRMLS_D)
/* WebDAV Access Control - RFC 3744 */
DCL_CONST(long, "METH_ACL", HTTP_ACL);
/* WebDAV Access Control - RFC 3744 */
DCL_CONST(long, "METH_ACL", HTTP_ACL);
+ /* cURL HTTP protocol versions */
+ DCL_CONST(long, "VERSION_1_0", CURL_HTTP_VERSION_1_0);
+ DCL_CONST(long, "VERSION_1_1", CURL_HTTP_VERSION_1_1);
+ DCL_CONST(long, "VERSION_NONE", CURL_HTTP_VERSION_NONE);
+
/*
* Auth Constants
*/
/*
* Auth Constants
*/
@@
-431,11
+435,11
@@
STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_
STATUS status = SUCCESS;
http_request_reset(obj->request);
STATUS status = SUCCESS;
http_request_reset(obj->request);
- HTTP_CHECK_CURL_INIT(obj->request->ch,
curl_easy_init(
), return FAILURE);
+ HTTP_CHECK_CURL_INIT(obj->request->ch,
http_curl_init(obj->request
), return FAILURE);
- obj->request->url = http_absolute_url(Z_STRVAL_P(GET_PROP(
obj,
url)));
+ obj->request->url = http_absolute_url(Z_STRVAL_P(GET_PROP(url)));
- switch (obj->request->meth = Z_LVAL_P(GET_PROP(
obj,
method)))
+ switch (obj->request->meth = Z_LVAL_P(GET_PROP(method)))
{
case HTTP_GET:
case HTTP_HEAD:
{
case HTTP_GET:
case HTTP_HEAD:
@@
-444,7
+448,7
@@
STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_
case HTTP_PUT:
{
php_stream_statbuf ssb;
case HTTP_PUT:
{
php_stream_statbuf ssb;
- php_stream *stream = php_stream_open_wrapper(Z_STRVAL_P(GET_PROP(
obj,
putFile)), "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
+ php_stream *stream = php_stream_open_wrapper(Z_STRVAL_P(GET_PROP(putFile)), "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
if (stream && !php_stream_stat(stream, &ssb)) {
obj->request->body = http_request_body_init_ex(obj->request->body, HTTP_REQUEST_BODY_UPLOADFILE, stream, ssb.sb.st_size, 1);
if (stream && !php_stream_stat(stream, &ssb)) {
obj->request->body = http_request_body_init_ex(obj->request->body, HTTP_REQUEST_BODY_UPLOADFILE, stream, ssb.sb.st_size, 1);
@@
-458,13
+462,13
@@
STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_
default:
{
/* check for raw post data */
default:
{
/* check for raw post data */
- zval *raw_data = GET_PROP(
obj,
rawPostData);
+ zval *raw_data = GET_PROP(rawPostData);
if (Z_STRLEN_P(raw_data)) {
if (Z_STRLEN_P(raw_data)) {
- zval *ctype = GET_PROP(
obj,
contentType);
+ zval *ctype = GET_PROP(contentType);
if (Z_STRLEN_P(ctype)) {
if (Z_STRLEN_P(ctype)) {
- zval **headers, *opts = GET_PROP(o
bj, o
ptions);
+ zval **headers, *opts = GET_PROP(options);
if ( (Z_TYPE_P(opts) == IS_ARRAY) &&
(SUCCESS == zend_hash_find(Z_ARRVAL_P(opts), "headers", sizeof("headers"), (void **) &headers)) &&
if ( (Z_TYPE_P(opts) == IS_ARRAY) &&
(SUCCESS == zend_hash_find(Z_ARRVAL_P(opts), "headers", sizeof("headers"), (void **) &headers)) &&
@@
-490,15
+494,17
@@
STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_
estrndup(Z_STRVAL_P(raw_data), Z_STRLEN_P(raw_data)), Z_STRLEN_P(raw_data), 1);
} else {
estrndup(Z_STRVAL_P(raw_data), Z_STRLEN_P(raw_data)), Z_STRLEN_P(raw_data), 1);
} else {
- zval *zfields = GET_PROP(
obj, postFields), *zfiles = GET_PROP(obj,
postFiles);
+ zval *zfields = GET_PROP(
postFields), *zfiles = GET_PROP(
postFiles);
HashTable *fields;
HashTable *files;
fields = (Z_TYPE_P(zfields) == IS_ARRAY) ? Z_ARRVAL_P(zfields) : NULL;
files = (Z_TYPE_P(zfiles) == IS_ARRAY) ? Z_ARRVAL_P(zfiles) : NULL;
HashTable *fields;
HashTable *files;
fields = (Z_TYPE_P(zfields) == IS_ARRAY) ? Z_ARRVAL_P(zfields) : NULL;
files = (Z_TYPE_P(zfiles) == IS_ARRAY) ? Z_ARRVAL_P(zfiles) : NULL;
- if (!(obj->request->body = http_request_body_fill(obj->request->body, fields, files))) {
- status = FAILURE;
+ if ((fields && zend_hash_num_elements(fields)) || (files && zend_hash_num_elements(files))) {
+ if (!(obj->request->body = http_request_body_fill(obj->request->body, fields, files))) {
+ status = FAILURE;
+ }
}
}
}
}
}
}
@@
-506,8
+512,8
@@
STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_
}
if (status == SUCCESS) {
}
if (status == SUCCESS) {
- zval *qdata = GET_PROP(
obj,
queryData);
- zval *options = GET_PROP(o
bj, o
ptions);
+ zval *qdata = GET_PROP(queryData);
+ zval *options = GET_PROP(options);
if (Z_STRLEN_P(qdata)) {
if (!strchr(obj->request->url, '?')) {
if (Z_STRLEN_P(qdata)) {
if (!strchr(obj->request->url, '?')) {
@@
-557,7
+563,7
@@
STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this
size_t body_len;
zval *headers, *message, *resp, *info;
size_t body_len;
zval *headers, *message, *resp, *info;
- if (zval_is_true(GET_PROP(
obj,
recordHistory))) {
+ if (zval_is_true(GET_PROP(recordHistory))) {
/* we need to act like a zipper, as we'll receive
* the requests and the responses in separate chains
* for redirects
/* we need to act like a zipper, as we'll receive
* the requests and the responses in separate chains
* for redirects
@@
-583,7
+589,7
@@
STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this
phpstr_fix(&obj->history);
}
phpstr_fix(&obj->history);
}
- UPD_PROP(
obj,
long, responseCode, msg->http.info.response.code);
+ UPD_PROP(long, responseCode, msg->http.info.response.code);
MAKE_STD_ZVAL(resp);
array_init(resp);
MAKE_STD_ZVAL(resp);
array_init(resp);
@@
-593,20
+599,24
@@
STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this
add_assoc_zval(resp, "headers", headers);
phpstr_data(PHPSTR(msg), &body, &body_len);
add_assoc_stringl(resp, "body", body, body_len, 0);
add_assoc_zval(resp, "headers", headers);
phpstr_data(PHPSTR(msg), &body, &body_len);
add_assoc_stringl(resp, "body", body, body_len, 0);
- SET_PROP(
obj,
responseData, resp);
+ SET_PROP(responseData, resp);
zval_ptr_dtor(&resp);
MAKE_STD_ZVAL(message);
zval_ptr_dtor(&resp);
MAKE_STD_ZVAL(message);
- ZVAL_OBJVAL(message, http_message_object_new_ex(http_message_object_ce, msg, NULL));
- SET_PROP(
obj,
responseMessage, message);
+ ZVAL_OBJVAL(message, http_message_object_new_ex(http_message_object_ce, msg, NULL)
, 0
);
+ SET_PROP(responseMessage, message);
zval_ptr_dtor(&message);
MAKE_STD_ZVAL(info);
array_init(info);
http_request_info(obj->request, Z_ARRVAL_P(info));
zval_ptr_dtor(&message);
MAKE_STD_ZVAL(info);
array_init(info);
http_request_info(obj->request, Z_ARRVAL_P(info));
- SET_PROP(
obj,
responseInfo, info);
+ SET_PROP(responseInfo, info);
zval_ptr_dtor(&info);
zval_ptr_dtor(&info);
-
+
+ if (zend_hash_exists(&Z_OBJCE_P(getThis())->function_table, "onfinish", sizeof("onfinish"))) {
+ zend_call_method_with_0_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "onfinish", NULL);
+ }
+
return SUCCESS;
}
}
return SUCCESS;
}
}
@@
-615,8
+625,7
@@
STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this
_http_request_object_set_options_subr(INTERNAL_FUNCTION_PARAM_PASSTHRU, (key), sizeof(key), (ow))
static inline void _http_request_object_set_options_subr(INTERNAL_FUNCTION_PARAMETERS, char *key, size_t len, int overwrite)
{
_http_request_object_set_options_subr(INTERNAL_FUNCTION_PARAM_PASSTHRU, (key), sizeof(key), (ow))
static inline void _http_request_object_set_options_subr(INTERNAL_FUNCTION_PARAMETERS, char *key, size_t len, int overwrite)
{
- zval *old_opts, *new_opts, *opts, **entry;
- getObject(http_request_object, obj);
+ zval *old_opts, *new_opts, *opts = NULL, **entry;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/!", &opts)) {
RETURN_FALSE;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/!", &opts)) {
RETURN_FALSE;
@@
-624,7
+633,7
@@
static inline void _http_request_object_set_options_subr(INTERNAL_FUNCTION_PARAM
MAKE_STD_ZVAL(new_opts);
array_init(new_opts);
MAKE_STD_ZVAL(new_opts);
array_init(new_opts);
- old_opts = GET_PROP(o
bj, o
ptions);
+ old_opts = GET_PROP(options);
if (Z_TYPE_P(old_opts) == IS_ARRAY) {
array_copy(old_opts, new_opts);
}
if (Z_TYPE_P(old_opts) == IS_ARRAY) {
array_copy(old_opts, new_opts);
}
@@
-644,7
+653,7
@@
static inline void _http_request_object_set_options_subr(INTERNAL_FUNCTION_PARAM
ZVAL_ADDREF(opts);
add_assoc_zval(new_opts, key, opts);
}
ZVAL_ADDREF(opts);
add_assoc_zval(new_opts, key, opts);
}
- SET_PROP(o
bj, o
ptions, new_opts);
+ SET_PROP(options, new_opts);
zval_ptr_dtor(&new_opts);
RETURN_TRUE;
zval_ptr_dtor(&new_opts);
RETURN_TRUE;
@@
-658,10
+667,8
@@
static inline void _http_request_get_options_subr(INTERNAL_FUNCTION_PARAMETERS,
IF_RETVAL_USED {
zval *opts, **options;
IF_RETVAL_USED {
zval *opts, **options;
- getObject(http_request_object, obj);
-
- opts = GET_PROP(obj, options);
+ opts = GET_PROP(options);
array_init(return_value);
if ( (Z_TYPE_P(opts) == IS_ARRAY) &&
array_init(return_value);
if ( (Z_TYPE_P(opts) == IS_ARRAY) &&
@@
-692,15
+699,14
@@
PHP_METHOD(HttpRequest, __construct)
int URL_len;
long meth = -1;
zval *options = NULL;
int URL_len;
long meth = -1;
zval *options = NULL;
- getObject(http_request_object, obj);
SET_EH_THROW_HTTP();
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sla", &URL, &URL_len, &meth, &options)) {
if (URL) {
SET_EH_THROW_HTTP();
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sla", &URL, &URL_len, &meth, &options)) {
if (URL) {
- UPD_STRL(
obj,
url, URL, URL_len);
+ UPD_STRL(url, URL, URL_len);
}
if (meth > -1) {
}
if (meth > -1) {
- UPD_PROP(
obj,
long, method, meth);
+ UPD_PROP(long, method, meth);
}
if (options) {
zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "setoptions", NULL, options);
}
if (options) {
zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "setoptions", NULL, options);
@@
-726,7
+732,6
@@
PHP_METHOD(HttpRequest, setOptions)
ulong idx = 0;
HashPosition pos;
zval *opts = NULL, *old_opts, *new_opts, *add_opts, **opt;
ulong idx = 0;
HashPosition pos;
zval *opts = NULL, *old_opts, *new_opts, *add_opts, **opt;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts)) {
RETURN_FALSE;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts)) {
RETURN_FALSE;
@@
-736,7
+741,7
@@
PHP_METHOD(HttpRequest, setOptions)
array_init(new_opts);
if (!opts || !zend_hash_num_elements(Z_ARRVAL_P(opts))) {
array_init(new_opts);
if (!opts || !zend_hash_num_elements(Z_ARRVAL_P(opts))) {
- SET_PROP(o
bj, o
ptions, new_opts);
+ SET_PROP(options, new_opts);
zval_ptr_dtor(&new_opts);
RETURN_TRUE;
}
zval_ptr_dtor(&new_opts);
RETURN_TRUE;
}
@@
-765,12
+770,12
@@
PHP_METHOD(HttpRequest, setOptions)
}
}
}
}
- old_opts = GET_PROP(o
bj, o
ptions);
+ old_opts = GET_PROP(options);
if (Z_TYPE_P(old_opts) == IS_ARRAY) {
array_copy(old_opts, new_opts);
}
array_merge(add_opts, new_opts);
if (Z_TYPE_P(old_opts) == IS_ARRAY) {
array_copy(old_opts, new_opts);
}
array_merge(add_opts, new_opts);
- SET_PROP(o
bj, o
ptions, new_opts);
+ SET_PROP(options, new_opts);
zval_ptr_dtor(&new_opts);
zval_ptr_dtor(&add_opts);
zval_ptr_dtor(&new_opts);
zval_ptr_dtor(&add_opts);
@@
-789,10
+794,7
@@
PHP_METHOD(HttpRequest, getOptions)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *options = GET_PROP(obj, options);
-
- RETURN_ZVAL(options, 1, 0);
+ RETURN_PROP(options);
}
}
/* }}} */
}
}
/* }}} */
@@
-933,13
+935,12
@@
PHP_METHOD(HttpRequest, setUrl)
{
char *URL = NULL;
int URL_len;
{
char *URL = NULL;
int URL_len;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &URL, &URL_len)) {
RETURN_FALSE;
}
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &URL, &URL_len)) {
RETURN_FALSE;
}
- UPD_STRL(
obj,
url, URL, URL_len);
+ UPD_STRL(url, URL, URL_len);
RETURN_TRUE;
}
/* }}} */
RETURN_TRUE;
}
/* }}} */
@@
-955,10
+956,7
@@
PHP_METHOD(HttpRequest, getUrl)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *url = GET_PROP(obj, url);
-
- RETURN_ZVAL(url, 1, 0);
+ RETURN_PROP(url);
}
}
/* }}} */
}
}
/* }}} */
@@
-975,13
+973,12
@@
PHP_METHOD(HttpRequest, getUrl)
PHP_METHOD(HttpRequest, setMethod)
{
long meth;
PHP_METHOD(HttpRequest, setMethod)
{
long meth;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &meth)) {
RETURN_FALSE;
}
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &meth)) {
RETURN_FALSE;
}
- UPD_PROP(
obj,
long, method, meth);
+ UPD_PROP(long, method, meth);
RETURN_TRUE;
}
/* }}} */
RETURN_TRUE;
}
/* }}} */
@@
-997,10
+994,7
@@
PHP_METHOD(HttpRequest, getMethod)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *method = GET_PROP(obj, method);
-
- RETURN_ZVAL(method, 1, 0);
+ RETURN_PROP(method);
}
}
/* }}} */
}
}
/* }}} */
@@
-1026,7
+1020,7
@@
PHP_METHOD(HttpRequest, setContentType)
}
HTTP_CHECK_CONTENT_TYPE(ctype, RETURN_FALSE);
}
HTTP_CHECK_CONTENT_TYPE(ctype, RETURN_FALSE);
- UPD_STRL(
obj,
contentType, ctype, ct_len);
+ UPD_STRL(contentType, ctype, ct_len);
RETURN_TRUE;
}
/* }}} */
RETURN_TRUE;
}
/* }}} */
@@
-1042,10
+1036,7
@@
PHP_METHOD(HttpRequest, getContentType)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *ctype = GET_PROP(obj, contentType);
-
- RETURN_ZVAL(ctype, 1, 0);
+ RETURN_PROP(contentType);
}
}
/* }}} */
}
}
/* }}} */
@@
-1071,7
+1062,7
@@
PHP_METHOD(HttpRequest, setQueryData)
}
if ((!qdata) || Z_TYPE_P(qdata) == IS_NULL) {
}
if ((!qdata) || Z_TYPE_P(qdata) == IS_NULL) {
- UPD_STRL(
obj,
queryData, "", 0);
+ UPD_STRL(queryData, "", 0);
} else if ((Z_TYPE_P(qdata) == IS_ARRAY) || (Z_TYPE_P(qdata) == IS_OBJECT)) {
char *query_data = NULL;
} else if ((Z_TYPE_P(qdata) == IS_ARRAY) || (Z_TYPE_P(qdata) == IS_OBJECT)) {
char *query_data = NULL;
@@
-1079,13
+1070,13
@@
PHP_METHOD(HttpRequest, setQueryData)
RETURN_FALSE;
}
RETURN_FALSE;
}
- UPD_PROP(
obj,
string, queryData, query_data);
+ UPD_PROP(string, queryData, query_data);
efree(query_data);
} else {
zval *orig = qdata;
convert_to_string_ex(&qdata);
efree(query_data);
} else {
zval *orig = qdata;
convert_to_string_ex(&qdata);
- UPD_STRL(
obj,
queryData, Z_STRVAL_P(qdata), Z_STRLEN_P(qdata));
+ UPD_STRL(queryData, Z_STRVAL_P(qdata), Z_STRLEN_P(qdata));
if (orig != qdata) {
zval_ptr_dtor(&qdata);
}
if (orig != qdata) {
zval_ptr_dtor(&qdata);
}
@@
-1105,10
+1096,7
@@
PHP_METHOD(HttpRequest, getQueryData)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *qdata = GET_PROP(obj, queryData);
-
- RETURN_ZVAL(qdata, 1, 0);
+ RETURN_PROP(queryData);
}
}
/* }}} */
}
}
/* }}} */
@@
-1127,19
+1115,18
@@
PHP_METHOD(HttpRequest, addQueryData)
zval *qdata, *old_qdata;
char *query_data = NULL;
size_t query_data_len = 0;
zval *qdata, *old_qdata;
char *query_data = NULL;
size_t query_data_len = 0;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &qdata)) {
RETURN_FALSE;
}
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &qdata)) {
RETURN_FALSE;
}
- old_qdata = GET_PROP(
obj,
queryData);
+ old_qdata = GET_PROP(queryData);
if (SUCCESS != http_urlencode_hash_ex(HASH_OF(qdata), 1, Z_STRVAL_P(old_qdata), Z_STRLEN_P(old_qdata), &query_data, &query_data_len)) {
RETURN_FALSE;
}
if (SUCCESS != http_urlencode_hash_ex(HASH_OF(qdata), 1, Z_STRVAL_P(old_qdata), Z_STRLEN_P(old_qdata), &query_data, &query_data_len)) {
RETURN_FALSE;
}
- UPD_STRL(
obj,
queryData, query_data, query_data_len);
+ UPD_STRL(queryData, query_data, query_data_len);
efree(query_data);
RETURN_TRUE;
efree(query_data);
RETURN_TRUE;
@@
-1159,7
+1146,6
@@
PHP_METHOD(HttpRequest, addQueryData)
PHP_METHOD(HttpRequest, addPostFields)
{
zval *post_data, *old_post, *new_post;
PHP_METHOD(HttpRequest, addPostFields)
{
zval *post_data, *old_post, *new_post;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &post_data)) {
RETURN_FALSE;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &post_data)) {
RETURN_FALSE;
@@
-1168,12
+1154,12
@@
PHP_METHOD(HttpRequest, addPostFields)
if (zend_hash_num_elements(Z_ARRVAL_P(post_data))) {
MAKE_STD_ZVAL(new_post);
array_init(new_post);
if (zend_hash_num_elements(Z_ARRVAL_P(post_data))) {
MAKE_STD_ZVAL(new_post);
array_init(new_post);
- old_post = GET_PROP(
obj,
postFields);
+ old_post = GET_PROP(postFields);
if (Z_TYPE_P(old_post) == IS_ARRAY) {
array_copy(old_post, new_post);
}
array_merge(post_data, new_post);
if (Z_TYPE_P(old_post) == IS_ARRAY) {
array_copy(old_post, new_post);
}
array_merge(post_data, new_post);
- SET_PROP(
obj,
postFields, new_post);
+ SET_PROP(postFields, new_post);
zval_ptr_dtor(&new_post);
}
zval_ptr_dtor(&new_post);
}
@@
-1194,7
+1180,6
@@
PHP_METHOD(HttpRequest, addPostFields)
PHP_METHOD(HttpRequest, setPostFields)
{
zval *post, *post_data = NULL;
PHP_METHOD(HttpRequest, setPostFields)
{
zval *post, *post_data = NULL;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!", &post_data)) {
RETURN_FALSE;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!", &post_data)) {
RETURN_FALSE;
@@
-1205,7
+1190,7
@@
PHP_METHOD(HttpRequest, setPostFields)
if (post_data && zend_hash_num_elements(Z_ARRVAL_P(post_data))) {
array_copy(post_data, post);
}
if (post_data && zend_hash_num_elements(Z_ARRVAL_P(post_data))) {
array_copy(post_data, post);
}
- SET_PROP(
obj,
postFields, post);
+ SET_PROP(postFields, post);
zval_ptr_dtor(&post);
RETURN_TRUE;
zval_ptr_dtor(&post);
RETURN_TRUE;
@@
-1223,10
+1208,7
@@
PHP_METHOD(HttpRequest, getPostFields)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *post = GET_PROP(obj, postFields);
-
- RETURN_ZVAL(post, 1, 0);
+ RETURN_PROP(postFields);
}
}
/* }}} */
}
}
/* }}} */
@@
-1247,7
+1229,6
@@
PHP_METHOD(HttpRequest, setRawPostData)
{
char *raw_data = NULL;
int data_len = 0;
{
char *raw_data = NULL;
int data_len = 0;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &raw_data, &data_len)) {
RETURN_FALSE;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &raw_data, &data_len)) {
RETURN_FALSE;
@@
-1257,7
+1238,7
@@
PHP_METHOD(HttpRequest, setRawPostData)
raw_data = "";
}
raw_data = "";
}
- UPD_STRL(
obj,
rawPostData, raw_data, data_len);
+ UPD_STRL(rawPostData, raw_data, data_len);
RETURN_TRUE;
}
/* }}} */
RETURN_TRUE;
}
/* }}} */
@@
-1275,19
+1256,18
@@
PHP_METHOD(HttpRequest, addRawPostData)
{
char *raw_data;
int data_len;
{
char *raw_data;
int data_len;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &raw_data, &data_len)) {
RETURN_FALSE;
}
if (data_len) {
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &raw_data, &data_len)) {
RETURN_FALSE;
}
if (data_len) {
- zval *data = zval_copy(IS_STRING, GET_PROP(
obj,
rawPostData));
+ zval *data = zval_copy(IS_STRING, GET_PROP(rawPostData));
Z_STRVAL_P(data) = erealloc(Z_STRVAL_P(data), (Z_STRLEN_P(data) += data_len) + 1);
Z_STRVAL_P(data)[Z_STRLEN_P(data)] = '\0';
memcpy(Z_STRVAL_P(data) + Z_STRLEN_P(data) - data_len, raw_data, data_len);
Z_STRVAL_P(data) = erealloc(Z_STRVAL_P(data), (Z_STRLEN_P(data) += data_len) + 1);
Z_STRVAL_P(data)[Z_STRLEN_P(data)] = '\0';
memcpy(Z_STRVAL_P(data) + Z_STRLEN_P(data) - data_len, raw_data, data_len);
- SET_PROP(
obj,
rawPostData, data);
+ SET_PROP(rawPostData, data);
zval_free(&data);
}
zval_free(&data);
}
@@
-1306,10
+1286,7
@@
PHP_METHOD(HttpRequest, getRawPostData)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *post = GET_PROP(obj, rawPostData);
-
- RETURN_ZVAL(post, 1, 0);
+ RETURN_PROP(rawPostData);
}
}
/* }}} */
}
}
/* }}} */
@@
-1332,7
+1309,6
@@
PHP_METHOD(HttpRequest, addPostFile)
zval *entry, *old_post, *new_post;
char *name, *file, *type = NULL;
int name_len, file_len, type_len = 0;
zval *entry, *old_post, *new_post;
char *name, *file, *type = NULL;
int name_len, file_len, type_len = 0;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s", &name, &name_len, &file, &file_len, &type, &type_len)) {
RETURN_FALSE;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s", &name, &name_len, &file, &file_len, &type, &type_len)) {
RETURN_FALSE;
@@
-1354,12
+1330,12
@@
PHP_METHOD(HttpRequest, addPostFile)
MAKE_STD_ZVAL(new_post);
array_init(new_post);
MAKE_STD_ZVAL(new_post);
array_init(new_post);
- old_post = GET_PROP(
obj,
postFiles);
+ old_post = GET_PROP(postFiles);
if (Z_TYPE_P(old_post) == IS_ARRAY) {
array_copy(old_post, new_post);
}
add_next_index_zval(new_post, entry);
if (Z_TYPE_P(old_post) == IS_ARRAY) {
array_copy(old_post, new_post);
}
add_next_index_zval(new_post, entry);
- SET_PROP(
obj,
postFiles, new_post);
+ SET_PROP(postFiles, new_post);
zval_ptr_dtor(&new_post);
RETURN_TRUE;
zval_ptr_dtor(&new_post);
RETURN_TRUE;
@@
-1380,7
+1356,6
@@
PHP_METHOD(HttpRequest, addPostFile)
PHP_METHOD(HttpRequest, setPostFiles)
{
zval *files = NULL, *post;
PHP_METHOD(HttpRequest, setPostFiles)
{
zval *files = NULL, *post;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!/", &files)) {
RETURN_FALSE;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!/", &files)) {
RETURN_FALSE;
@@
-1391,7
+1366,7
@@
PHP_METHOD(HttpRequest, setPostFiles)
if (files && (Z_TYPE_P(files) == IS_ARRAY)) {
array_copy(files, post);
}
if (files && (Z_TYPE_P(files) == IS_ARRAY)) {
array_copy(files, post);
}
- SET_PROP(
obj,
postFiles, post);
+ SET_PROP(postFiles, post);
zval_ptr_dtor(&post);
RETURN_TRUE;
zval_ptr_dtor(&post);
RETURN_TRUE;
@@
-1409,10
+1384,7
@@
PHP_METHOD(HttpRequest, getPostFiles)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *files = GET_PROP(obj, postFiles);
-
- RETURN_ZVAL(files, 1, 0);
+ RETURN_PROP(postFiles);
}
}
/* }}} */
}
}
/* }}} */
@@
-1430,13
+1402,12
@@
PHP_METHOD(HttpRequest, setPutFile)
{
char *file = "";
int file_len = 0;
{
char *file = "";
int file_len = 0;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &file, &file_len)) {
RETURN_FALSE;
}
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &file, &file_len)) {
RETURN_FALSE;
}
- UPD_STRL(
obj,
putFile, file, file_len);
+ UPD_STRL(putFile, file, file_len);
RETURN_TRUE;
}
/* }}} */
RETURN_TRUE;
}
/* }}} */
@@
-1452,10
+1423,7
@@
PHP_METHOD(HttpRequest, getPutFile)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *file = GET_PROP(obj, putFile);
-
- RETVAL_ZVAL(file, 1, 0);
+ RETURN_PROP(putFile);
}
}
/* }}} */
}
}
/* }}} */
@@
-1476,10
+1444,7
@@
PHP_METHOD(HttpRequest, getResponseData)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *data = GET_PROP(obj, responseData);
-
- RETURN_ZVAL(data, 1, 0);
+ RETURN_PROP(responseData);
}
}
/* }}} */
}
}
/* }}} */
@@
-1503,13
+1468,12
@@
PHP_METHOD(HttpRequest, getResponseHeader)
zval *data, **headers, **header;
char *header_name = NULL;
int header_len = 0;
zval *data, **headers, **header;
char *header_name = NULL;
int header_len = 0;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &header_name, &header_len)) {
RETURN_FALSE;
}
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &header_name, &header_len)) {
RETURN_FALSE;
}
- data = GET_PROP(
obj,
responseData);
+ data = GET_PROP(responseData);
if ( (Z_TYPE_P(data) == IS_ARRAY) &&
(SUCCESS == zend_hash_find(Z_ARRVAL_P(data), "headers", sizeof("headers"), (void **) &headers)) &&
(Z_TYPE_PP(headers) == IS_ARRAY)) {
if ( (Z_TYPE_P(data) == IS_ARRAY) &&
(SUCCESS == zend_hash_find(Z_ARRVAL_P(data), "headers", sizeof("headers"), (void **) &headers)) &&
(Z_TYPE_PP(headers) == IS_ARRAY)) {
@@
-1548,7
+1512,6
@@
PHP_METHOD(HttpRequest, getResponseCookie)
zval *data, **headers;
char *cookie_name = NULL;
int cookie_len = 0;
zval *data, **headers;
char *cookie_name = NULL;
int cookie_len = 0;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &cookie_name, &cookie_len)) {
RETURN_FALSE;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &cookie_name, &cookie_len)) {
RETURN_FALSE;
@@
-1556,7
+1519,7
@@
PHP_METHOD(HttpRequest, getResponseCookie)
array_init(return_value);
array_init(return_value);
- data = GET_PROP(
obj,
responseData);
+ data = GET_PROP(responseData);
if ( (Z_TYPE_P(data) == IS_ARRAY) &&
(SUCCESS == zend_hash_find(Z_ARRVAL_P(data), "headers", sizeof("headers"), (void **) &headers)) &&
(Z_TYPE_PP(headers) == IS_ARRAY)) {
if ( (Z_TYPE_P(data) == IS_ARRAY) &&
(SUCCESS == zend_hash_find(Z_ARRVAL_P(data), "headers", sizeof("headers"), (void **) &headers)) &&
(Z_TYPE_PP(headers) == IS_ARRAY)) {
@@
-1649,8
+1612,7
@@
PHP_METHOD(HttpRequest, getResponseBody)
IF_RETVAL_USED {
zval **body;
IF_RETVAL_USED {
zval **body;
- getObject(http_request_object, obj);
- zval *data = GET_PROP(obj, responseData);
+ zval *data = GET_PROP(responseData);
if ( (Z_TYPE_P(data) == IS_ARRAY) &&
(SUCCESS == zend_hash_find(Z_ARRVAL_P(data), "body", sizeof("body"), (void **) &body))) {
if ( (Z_TYPE_P(data) == IS_ARRAY) &&
(SUCCESS == zend_hash_find(Z_ARRVAL_P(data), "body", sizeof("body"), (void **) &body))) {
@@
-1676,10
+1638,7
@@
PHP_METHOD(HttpRequest, getResponseCode)
NO_ARGS;
IF_RETVAL_USED {
NO_ARGS;
IF_RETVAL_USED {
- getObject(http_request_object, obj);
- zval *code = GET_PROP(obj, responseCode);
-
- RETVAL_ZVAL(code, 1, 0);
+ RETURN_PROP(responseCode);
}
}
/* }}} */
}
}
/* }}} */
@@
-1706,13
+1665,12
@@
PHP_METHOD(HttpRequest, getResponseInfo)
zval *info, **infop;
char *info_name = NULL;
int info_len = 0;
zval *info, **infop;
char *info_name = NULL;
int info_len = 0;
- getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &info_name, &info_len)) {
RETURN_FALSE;
}
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &info_name, &info_len)) {
RETURN_FALSE;
}
- info = GET_PROP(
obj,
responseInfo);
+ info = GET_PROP(responseInfo);
if (Z_TYPE_P(info) != IS_ARRAY) {
RETURN_FALSE;
if (Z_TYPE_P(info) != IS_ARRAY) {
RETURN_FALSE;
@@
-1751,12
+1709,11
@@
PHP_METHOD(HttpRequest, getResponseMessage)
IF_RETVAL_USED {
zval *message;
IF_RETVAL_USED {
zval *message;
- getObject(http_request_object, obj);
SET_EH_THROW_HTTP();
SET_EH_THROW_HTTP();
- message = GET_PROP(
obj,
responseMessage);
+ message = GET_PROP(responseMessage);
if (Z_TYPE_P(message) == IS_OBJECT) {
if (Z_TYPE_P(message) == IS_OBJECT) {
- RETVAL_OBJECT(message);
+ RETVAL_OBJECT(message
, 1
);
} else {
RETVAL_NULL();
}
} else {
RETVAL_NULL();
}
@@
-1793,7
+1750,7
@@
PHP_METHOD(HttpRequest, getRequestMessage)
SET_EH_THROW_HTTP();
if ((msg = http_message_parse(PHPSTR_VAL(&obj->request->conv.request), PHPSTR_LEN(&obj->request->conv.request)))) {
SET_EH_THROW_HTTP();
if ((msg = http_message_parse(PHPSTR_VAL(&obj->request->conv.request), PHPSTR_LEN(&obj->request->conv.request)))) {
-
ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL)
);
+
RETVAL_OBJVAL(http_message_object_new_ex(http_message_object_ce, msg, NULL), 0
);
}
SET_EH_NORMAL();
}
}
SET_EH_NORMAL();
}
@@
-1867,7
+1824,7
@@
PHP_METHOD(HttpRequest, getHistory)
SET_EH_THROW_HTTP();
if ((msg = http_message_parse(PHPSTR_VAL(&obj->history), PHPSTR_LEN(&obj->history)))) {
SET_EH_THROW_HTTP();
if ((msg = http_message_parse(PHPSTR_VAL(&obj->history), PHPSTR_LEN(&obj->history)))) {
-
ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL)
);
+
RETVAL_OBJVAL(http_message_object_new_ex(http_message_object_ce, msg, NULL), 0
);
}
SET_EH_NORMAL();
}
}
SET_EH_NORMAL();
}
@@
-1947,7
+1904,7
@@
PHP_METHOD(HttpRequest, send)
} else if (SUCCESS == http_request_object_requesthandler(obj, getThis())) {
http_request_exec(obj->request);
if (SUCCESS == http_request_object_responsehandler(obj, getThis())) {
} else if (SUCCESS == http_request_object_requesthandler(obj, getThis())) {
http_request_exec(obj->request);
if (SUCCESS == http_request_object_responsehandler(obj, getThis())) {
- RETVAL_OBJECT(GET_PROP(
obj, responseMessage)
);
+ RETVAL_OBJECT(GET_PROP(
responseMessage), 1
);
}
}
}
}