X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_object.c;h=2ed979789b009c8a93b2c983baca769b5a50a946;hp=cad4bd63783757342c18819336a1714b9edbc1ea;hb=34644fd4c700fb55c3a2c2ff9966d0f5e7572509;hpb=df7aeca1431cca4653468825a00b68b240c6ddbb diff --git a/http_request_object.c b/http_request_object.c index cad4bd6..2ed9797 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -219,8 +219,6 @@ HTTP_END_ARGS; #define http_request_object_declare_default_properties() _http_request_object_declare_default_properties(TSRMLS_C) static inline void _http_request_object_declare_default_properties(TSRMLS_D); -#define http_request_object_clone_obj _http_request_object_clone_obj -static inline zend_object_value _http_request_object_clone_obj(zval *object TSRMLS_DC); zend_class_entry *http_request_object_ce; zend_function_entry http_request_object_fe[] = { @@ -780,6 +778,7 @@ PHP_METHOD(HttpRequest, setOptions) { char *key = NULL; ulong idx = 0; + HashPosition pos; zval *opts = NULL, *old_opts, **opt; getObject(http_request_object, obj); @@ -797,7 +796,7 @@ PHP_METHOD(HttpRequest, setOptions) } /* some options need extra attention -- thus cannot use array_merge() directly */ - FOREACH_KEYVAL(opts, key, idx, opt) { + FOREACH_KEYVAL(pos, opts, key, idx, opt) { if (key) { if (!strcmp(key, "headers")) { zval **headers; @@ -1666,15 +1665,17 @@ PHP_METHOD(HttpRequest, getResponseCookie) ulong idx = 0; char *key = NULL; zval **header = NULL; + HashPosition pos1; - convert_to_array_ex(headers); - FOREACH_HASH_KEYVAL(Z_ARRVAL_PP(headers), key, idx, header) { + convert_to_array(*headers); + FOREACH_HASH_KEYVAL(pos1, Z_ARRVAL_PP(headers), key, idx, header) { if (key && !strcasecmp(key, "Set-Cookie")) { /* several cookies? */ if (Z_TYPE_PP(header) == IS_ARRAY) { zval **cookie; + HashPosition pos2; - FOREACH_HASH_VAL(Z_ARRVAL_PP(header), cookie) { + FOREACH_HASH_VAL(pos2, Z_ARRVAL_PP(header), cookie) { zval *cookie_hash; MAKE_STD_ZVAL(cookie_hash); array_init(cookie_hash); @@ -1876,6 +1877,13 @@ PHP_METHOD(HttpRequest, getResponseMessage) * references the last received response. Use HttpMessage::getParentMessage() * to access the data of previously sent requests whithin this request * cycle. + * + * Note that the internal request message is immutable, that means that the + * request message received through HttpRequest::getRequestMessage() will + * always look the same for the same request, regardless of any changes you + * may have made to the returned object. + * + * Throws HttpMalformedHeadersException, HttpEncodingException. */ PHP_METHOD(HttpRequest, getRequestMessage) { @@ -1887,7 +1895,7 @@ PHP_METHOD(HttpRequest, getRequestMessage) SET_EH_THROW_HTTP(); if (msg = http_message_parse(PHPSTR_VAL(&obj->request), PHPSTR_LEN(&obj->request))) { - RETVAL_OBJVAL(http_message_object_new_ex(http_message_object_ce, msg, NULL)); + ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL)); } SET_EH_NORMAL(); } @@ -1907,7 +1915,11 @@ PHP_METHOD(HttpRequest, getRequestMessage) * The object references the last received response, use HttpMessage::getParentMessage() * to access the data of previously sent requests and received responses. * - * Throws HttpMalformedHeaderException. + * Note that the internal history is immutable, that means that any changes + * you make the the message list won't affect a history message list newly + * created by another call to HttpRequest::getHistory(). + * + * Throws HttpMalformedHeaderException, HttpEncodingException. */ PHP_METHOD(HttpRequest, getHistory) { @@ -1919,7 +1931,7 @@ PHP_METHOD(HttpRequest, getHistory) SET_EH_THROW_HTTP(); if (msg = http_message_parse(PHPSTR_VAL(&obj->history), PHPSTR_LEN(&obj->history))) { - RETVAL_OBJVAL(http_message_object_new_ex(http_message_object_ce, msg, NULL)); + ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL)); } SET_EH_NORMAL(); } @@ -1945,6 +1957,10 @@ PHP_METHOD(HttpRequest, clearHistory) * * Returns the received response as HttpMessage object. * + * NOTE: While an exception may be thrown, the transfer could have succeeded + * at least partially, so you might want to check the return values of various + * HttpRequest::getResponse*() methods. + * * Throws HttpRuntimeException, HttpRequestException, * HttpMalformedHeaderException, HttpEncodingException. *