cvs: pecl(R_1_5) /http http_functions.c /http/tests negotiation_001.phpt
| From: | Michael Wallner | Date: | Wed, 29 Aug 2007 16:23:24 +0000 |
| Subject: | cvs: pecl(R_1_5) /http http_functions.c /http/tests negotiation_001.phpt | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-8481@lists.php.net to get a copy of this message | ||
mike Wed Aug 29 16:23:24 2007 UTC
Modified files: (Branch: R_1_5)
/pecl/http http_functions.c
/pecl/http/tests negotiation_001.phpt
Log:
MFH: fix bug #11929
http://cvs.php.net/viewvc.cgi/pecl/http/http_functions.c?r1=1.166&r2=1.166.2.1&diff_format=u
Index: pecl/http/http_functions.c
diff -u pecl/http/http_functions.c:1.166 pecl/http/http_functions.c:1.166.2.1
--- pecl/http/http_functions.c:1.166 Tue Mar 27 12:17:02 2007
+++ pecl/http/http_functions.c Wed Aug 29 16:23:24 2007
@@ -10,7 +10,7 @@
+--------------------------------------------------------------------+
*/
-/* $Id: http_functions.c,v 1.166 2007/03/27 12:17:02 mike Exp $ */
+/* $Id: http_functions.c,v 1.166.2.1 2007/08/29 16:23:24 mike Exp $ */
#define HTTP_WANT_SAPI
#define HTTP_WANT_CURL
@@ -148,6 +148,17 @@
}
/* }}} */
+#define HTTP_DO_NEGOTIATE_DEFAULT(supported) \
+ { \
+ zval **value; \
+ \
+ zend_hash_internal_pointer_reset(Z_ARRVAL_P(supported)); \
+ if (SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(supported), (void *) &value)) { \
+ RETVAL_ZVAL(*value, 1, 0); \
+ } else { \
+ RETVAL_NULL(); \
+ } \
+ }
#define HTTP_DO_NEGOTIATE(type, supported, rs_array) \
{ \
HashTable *result; \
@@ -156,10 +167,10 @@
uint key_len; \
ulong idx; \
\
- if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key, &key_len, &idx,
1, NULL)) { \
+ if (zend_hash_num_elements(result) && HASH_KEY_IS_STRING ==
zend_hash_get_current_key_ex(result, &key, &key_len, &idx, 1, NULL)) { \
RETVAL_STRINGL(key, key_len-1, 0); \
} else { \
- RETVAL_NULL(); \
+ HTTP_DO_NEGOTIATE_DEFAULT(supported); \
} \
\
if (rs_array) { \
@@ -170,14 +181,7 @@
FREE_HASHTABLE(result); \
\
} else { \
- zval **value; \
- \
- zend_hash_internal_pointer_reset(Z_ARRVAL_P(supported)); \
- if (SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(supported), (void *) &value)) { \
- RETVAL_ZVAL(*value, 1, 0); \
- } else { \
- RETVAL_NULL(); \
- } \
+ HTTP_DO_NEGOTIATE_DEFAULT(supported); \
\
if (rs_array) { \
HashPosition pos; \
http://cvs.php.net/viewvc.cgi/pecl/http/tests/negotiation_001.phpt?r1=1.6&r2=1.6.4.1&diff_format=u
Index: pecl/http/tests/negotiation_001.phpt
diff -u pecl/http/tests/negotiation_001.phpt:1.6 pecl/http/tests/negotiation_001.phpt:1.6.4.1
--- pecl/http/tests/negotiation_001.phpt:1.6 Wed Nov 22 10:50:11 2006
+++ pecl/http/tests/negotiation_001.phpt Wed Aug 29 16:23:24 2007
@@ -26,10 +26,14 @@
var_dump(http_negotiate_charset($csets[0], $cresult));
var_dump(http_negotiate_content_type($ctype[0]));
var_dump(http_negotiate_content_type($ctype[0], $tresult));
+var_dump(http_negotiate_language(array("unknown")));
+var_dump(http_negotiate_charset(array("unknown")));
+var_dump(http_negotiate_content_type(array("unknown")));
print_r($lresult);
print_r($cresult);
print_r($tresult);
echo "Done\n";
+?>
--EXPECTF--
%sTEST
string(2) "de"
@@ -38,6 +42,9 @@
string(10) "iso-8859-1"
string(21) "application/xhtml+xml"
string(21) "application/xhtml+xml"
+string(7) "unknown"
+string(7) "unknown"
+string(7) "unknown"
Array
(
[de] => 900