- http_request_defaults() already takes care of resetting curl options so check strin...
[m6w6/ext-http] / http_headers_api.c
index c04664e9b486afd21ea5971309c7767ee52e1e96..96110d337779e2441f56668f9ab0a9db92463aa7 100644 (file)
@@ -6,7 +6,7 @@
     | modification, are permitted provided that the conditions mentioned |
     | in the accompanying LICENSE file are met.                          |
     +--------------------------------------------------------------------+
-    | Copyright (c) 2004-2005, Michael Wallner <mike@php.net>            |
+    | Copyright (c) 2004-2006, Michael Wallner <mike@php.net>            |
     +--------------------------------------------------------------------+
 */
 
 #include "php_http_api.h"
 #include "php_http_headers_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 #ifndef HTTP_DBG_NEG
 #      define HTTP_DBG_NEG 0
 #endif
 
-/* {{{ */
-PHP_MINIT_FUNCTION(http_headers)
-{
-       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)
 {
@@ -357,10 +343,9 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
                header_len = strlen(header) + 1;
        }
        line = header;
-
-       while (header_len >= (size_t) (line - begin)) {
+       
+       if (header_len) do {
                int value_len = 0;
-               /* note: valgrind may choke on that -- should be safe though */
                switch (*line++)
                {
                        case ':':
@@ -372,7 +357,7 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
                        case 0:
                                --value_len; /* we don't have CR so value length is one char less */
                        case '\n':
-                               if ((!(*line - 1)) || ((*line != ' ') && (*line != '\t'))) {
+                               if ((!*(line - 1)) || ((*line != ' ') && (*line != '\t'))) {
                                        http_info i;
                                        
                                        /* response/request line */
@@ -429,7 +414,8 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
                                }
                        break;
                }
-       }
+       } while (header_len > (size_t) (line - begin));
+
        return SUCCESS;
 }
 /* }}} */