* medthod docs
[m6w6/ext-http] / http_api.c
index e1d6e1b43bd9be29c9dbb6a63dd7e34096e664c5..4032f787c08cd25f01e1695f5b3cc425d16215db 100644 (file)
@@ -1378,35 +1378,36 @@ PHP_HTTP_API STATUS _http_chunked_decode(const char *encoded,
 
 /* {{{ proto STATUS http_split_response_ex(char *, size_t, zval *, zval *) */
 PHP_HTTP_API STATUS _http_split_response_ex(char *response,
-       size_t response_len, zval *zheaders, zval *zbody TSRMLS_DC)
+       size_t response_len, HashTable *headers, char **body, size_t *body_len TSRMLS_DC)
 {
-       char *body = NULL;
        char *header = response;
+       *body = NULL;
 
        while (0 < (response_len - (response - header + 4))) {
                if (    (*response++ == '\r') &&
                                (*response++ == '\n') &&
                                (*response++ == '\r') &&
                                (*response++ == '\n')) {
-                       body = response;
+                       *body = response;
                        break;
                }
        }
 
-       if (body && (response_len - (body - header))) {
-               ZVAL_STRINGL(zbody, body, response_len - (body - header) - 1, 1);
-       } else {
-               Z_TYPE_P(zbody) = IS_NULL;
+       if (*body && (*body_len = response_len - (*body - header))) {
+               *body = estrndup(*body, *body_len - 1);
        }
 
-       return http_parse_headers(header, body ? body - header : response_len, zheaders);
+       return http_parse_headers(header, *body ? *body - header : response_len, headers);
 }
 /* }}} */
 
 /* {{{ STATUS http_parse_headers(char *, long, zval *) */
-PHP_HTTP_API STATUS _http_parse_headers(char *header, int header_len, zval *array TSRMLS_DC)
+PHP_HTTP_API STATUS _http_parse_headers(char *header, int header_len, HashTable *headers TSRMLS_DC)
 {
        char *colon = NULL, *line = NULL, *begin = header;
+       zval array;
+       
+       Z_ARRVAL(array) = headers;
 
        if (header_len < 2) {
                return FAILURE;
@@ -1415,7 +1416,7 @@ PHP_HTTP_API STATUS _http_parse_headers(char *header, int header_len, zval *arra
        /* status code */
        if (!strncmp(header, "HTTP/1.", 7)) {
                char *end = strstr(header, HTTP_CRLF);
-               add_assoc_stringl(array, "Status",
+               add_assoc_stringl(&array, "Status",
                        header + sizeof("HTTP/1.x ") - 1,
                        end - (header + sizeof("HTTP/1.x ") - 1), 1);
                header = end + 2;
@@ -1445,9 +1446,9 @@ PHP_HTTP_API STATUS _http_parse_headers(char *header, int header_len, zval *arra
 
                                                if (value_len < 1) {
                                                        /* hm, empty header? */
-                                                       add_assoc_stringl(array, key, "", 0, 1);
+                                                       add_assoc_stringl(&array, key, "", 0, 1);
                                                } else {
-                                                       add_assoc_stringl(array, key, colon, value_len, 1);
+                                                       add_assoc_stringl(&array, key, colon, value_len, 1);
                                                }
                                                efree(key);
                                        }
@@ -1572,7 +1573,7 @@ PHP_HTTP_API STATUS _http_auth_credentials(char **user, char **pass TSRMLS_DC)
 
 #ifndef ZEND_ENGINE_2
 /* {{{ php_url_encode_hash
-       Author: Sarah Golemon <pollita@php.net> */
+       Author: Sara Golemon <pollita@php.net> */
 PHP_HTTP_API STATUS php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
                                const char *num_prefix, int num_prefix_len,
                                const char *key_prefix, int key_prefix_len,
@@ -1743,4 +1744,5 @@ PHP_HTTP_API STATUS php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
  * End:
  * vim600: noet sw=4 ts=4 fdm=marker
  * vim<600: noet sw=4 ts=4
- */
\ No newline at end of file
+ */
+