- add note about SSL connect errors on windows due to LIB/DLL mismatches
[m6w6/ext-http] / http_headers_api.c
index 55be354afbc50feaf56817e64812647511b1b6ac..2af2da0d71258cd0387ca7d78601fe642a419a96 100644 (file)
@@ -37,6 +37,18 @@ ZEND_EXTERN_MODULE_GLOBALS(http);
 #      define HTTP_DBG_NEG 0
 #endif
 
+/* {{{ STATUS http_headers_global_init() */
+STATUS _http_headers_global_init(INIT_FUNC_ARGS)
+{
+       HTTP_LONG_CONSTANT("HTTP_REDIRECT", HTTP_REDIRECT);
+       HTTP_LONG_CONSTANT("HTTP_REDIRECT_PERM", HTTP_REDIRECT_PERM);
+       HTTP_LONG_CONSTANT("HTTP_REDIRECT_POST", HTTP_REDIRECT_POST);
+       HTTP_LONG_CONSTANT("HTTP_REDIRECT_TEMP", HTTP_REDIRECT_TEMP);
+       
+       return SUCCESS;
+}
+/* }}} */
+
 /* {{{ static int http_sort_q(const void *, const void *) */
 static int http_sort_q(const void *a, const void *b TSRMLS_DC)
 {
@@ -81,7 +93,7 @@ char *_http_negotiate_language_func(const char *test, double *quality, HashTable
                        if (    (!strncasecmp(Z_STRVAL_PP(value), test, len)) &&
                                        (       (Z_STRVAL_PP(value)[len] == '\0') || 
                                                (Z_STRVAL_PP(value)[len] == '-'))) {
-                               *quality /= 2;
+                               *quality *= .9;
                                return Z_STRVAL_PP(value);
                        }
                }
@@ -152,11 +164,9 @@ PHP_HTTP_API HashTable *_http_negotiate_q(const char *header, HashTable *support
                                if (separator = strchr(Z_STRVAL_PP(entry), ';')) {
                                        const char *ptr = separator;
                                        
-                                       do {
-                                               ++ptr;
-                                       } while ((*ptr == ' ') || (*ptr == 'q') || (*ptr == '='));
+                                       while (*++ptr && !isdigit(*ptr));
                                        
-                                       quality = strtod(ptr, NULL);
+                                       quality = atof(ptr);
                                        identifier = estrndup(Z_STRVAL_PP(entry), separator - Z_STRVAL_PP(entry));
                                } else {
                                        quality = 1000.0 - i++;
@@ -333,7 +343,8 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
        size_t header_len;
        zval array;
 
-       Z_ARRVAL(array) = headers;
+       INIT_ZARR(array, headers);
+       
        if (body) {
                header_len = body - header;
        } else {
@@ -343,7 +354,7 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
 
        while (header_len >= (size_t) (line - begin)) {
                int value_len = 0;
-
+               /* note: valgrind may choke on that -- should be safe though */
                switch (*line++)
                {
                        case ':':