projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
- improve http_redirect()
[m6w6/ext-http]
/
http_request_object.c
diff --git
a/http_request_object.c
b/http_request_object.c
index 7eb00d493809e176c1bce075413d84f364113529..60c79dda73be7739ab55914ca241894d250b38ca 100644
(file)
--- a/
http_request_object.c
+++ b/
http_request_object.c
@@
-302,7
+302,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
+337,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
+406,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,7
+439,7
@@
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(url)));
obj->request->url = http_absolute_url(Z_STRVAL_P(GET_PROP(url)));
@@
-497,8
+505,10
@@
STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_
fields = (Z_TYPE_P(zfields) == IS_ARRAY) ? Z_ARRVAL_P(zfields) : NULL;
files = (Z_TYPE_P(zfiles) == IS_ARRAY) ? Z_ARRVAL_P(zfiles) : NULL;
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;
+ }
}
}
}
}
}
}
@@
-619,7
+629,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;
+ zval *old_opts, *new_opts, *opts
= NULL
, **entry;
getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/!", &opts)) {
getObject(http_request_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/!", &opts)) {