- enable zlib by default
authorMichael Wallner <mike@php.net>
Tue, 10 Jan 2006 15:55:13 +0000 (15:55 +0000)
committerMichael Wallner <mike@php.net>
Tue, 10 Jan 2006 15:55:13 +0000 (15:55 +0000)
- simplify request method info
- fix tests; run-tests ENV support has changed drastically

16 files changed:
LICENSE
config.m4
http.c
http_url_api.c
php_http.h
tests/negotiation_001.phpt
tests/send_data_001.phpt
tests/send_data_002.phpt
tests/send_data_003.phpt
tests/send_data_005.phpt
tests/send_data_006.phpt
tests/send_file_005.phpt
tests/send_file_009.phpt
tests/send_file_010.phpt
tests/send_file_011.phpt
tests/send_file_013.phpt

diff --git a/LICENSE b/LICENSE
index a54036e..2bfd876 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2005, Michael Wallner <mike@iworks.at>.
+Copyright (c) 2004-2006, Michael Wallner <mike@iworks.at>.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without 
@@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 The date parser in file http_date_api.c is derived from the implementation
 found in the original libcurl source, licensed under the following conditions:
 
-Copyright (c) 1996 - 2005, Daniel Stenberg, <daniel@haxx.se>.
+Copyright (c) 1996 - 2006, Daniel Stenberg, <daniel@haxx.se>.
 All rights reserved.
 
 Permission to use, copy, modify, and distribute this software for any purpose
@@ -44,3 +44,4 @@ OR OTHER DEALINGS IN THE SOFTWARE.
 Except as contained in this notice, the name of a copyright holder shall not
 be used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization of the copyright holder.
+
index 0afce19..0d1c283 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -9,7 +9,7 @@ PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP request support]
                            HTTP: with cURL request support], "yes")
 PHP_ARG_WITH([http-zlib-compression], [whether to enable zlib encodings support],
 [  --with-http-zlib-compression[=LIBZDIR]
-                           HTTP: with zlib encodings support])
+                           HTTP: with zlib encodings support], "yes")
 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
 [  --with-http-magic-mime[=LIBMAGICDIR]
                            HTTP: with magic mime response content type guessing])
diff --git a/http.c b/http.c
index f5f66a7..05244d1 100644 (file)
--- a/http.c
+++ b/http.c
@@ -345,6 +345,14 @@ PHP_MINFO_FUNCTION(http)
 #      ifndef WONKY
                        "HttpResponse"
 #      endif
+#endif
+               );
+               php_info_print_table_row(2, "Output Handlers", "ob_deflatehandler, ob_inflatehandler, ob_etaghandler");
+               php_info_print_table_row(2, "Stream Filters", 
+#ifndef ZEND_ENGINE_2
+                       "none"
+#else
+                       "http.chunked_decode, http.chunked_encode, http.deflate, http.inflate"
 #endif
                );
        }
@@ -377,17 +385,13 @@ PHP_MINFO_FUNCTION(http)
        {
                int i;
                getGlobals(G);
-               struct _entry {char *name; char *cnst;} *entry;
-               phpstr *known_request_methods = phpstr_new();
                phpstr *custom_request_methods = phpstr_new();
+               phpstr *known_request_methods = phpstr_from_string(HTTP_KNOWN_METHODS, lenof(HTTP_KNOWN_METHODS));
+               http_request_method_entry **ptr = G->request.methods.custom.entries;
 
-               for (i = HTTP_MIN_REQUEST_METHOD; i < HTTP_MAX_REQUEST_METHOD; ++i) {
-                       phpstr_appendl(known_request_methods, http_request_method_name(i));
-                       phpstr_appends(known_request_methods, ", ");
-               }
                for (i = 0; i < G->request.methods.custom.count; ++i) {
-                       if ((entry = ((struct _entry **) G->request.methods.custom.entries)[i])) {
-                               phpstr_appendf(custom_request_methods, "%s, ", entry->name);
+                       if (ptr[i]) {
+                               phpstr_appendf(custom_request_methods, "%s, ", ptr[i]->name);
                        }
                }
 
@@ -398,7 +402,7 @@ PHP_MINFO_FUNCTION(http)
                php_info_print_table_row(2, "Known", PHPSTR_VAL(known_request_methods));
                php_info_print_table_row(2, "Custom",
                        PHPSTR_LEN(custom_request_methods) ? PHPSTR_VAL(custom_request_methods) : "none registered");
-               php_info_print_table_row(2, "Allowed", strlen(HTTP_G(request).methods.allowed) ? HTTP_G(request).methods.allowed : "(ANY)");
+               php_info_print_table_row(2, "Allowed", strlen(G->request.methods.allowed) ? G->request.methods.allowed : "(ANY)");
                
                phpstr_free(&known_request_methods);
                phpstr_free(&custom_request_methods);
index 517ee1a..6ca3351 100644 (file)
@@ -47,7 +47,7 @@ PHP_HTTP_API char *_http_absolute_url(const char *url TSRMLS_DC)
 /* {{{ void http_build_url(const php_url *, const php_url *, php_url **, char **, size_t *) */
 PHP_HTTP_API void _http_build_url(const php_url *old_url, const php_url *new_url, php_url **url_ptr, char **url_str, size_t *url_len TSRMLS_DC)
 {
-#if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
+#ifdef HTTP_HAVE_NETDB
        struct servent *se;
 #endif
        php_url *url = emalloc(sizeof(php_url));
@@ -70,14 +70,14 @@ PHP_HTTP_API void _http_build_url(const php_url *old_url, const php_url *new_url
                                url->scheme = estrndup("https", lenof("https"));
                        break;
 
-#if !defined(PHP_WIN32) && !defined(HAVE_NETDB_H)
+#ifndef HTTP_HAVE_NETDB
                        default:
 #endif
                        case 80:
                                url->scheme = estrndup("http", lenof("http"));
                        break;
                        
-#if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
+#ifdef HTTP_HAVE_NETDB
                        default:
                                if ((se = getservbyport(htons(url->port), "tcp")) && se->s_name) {
                                        url->scheme = estrdup(se->s_name);
@@ -139,7 +139,7 @@ PHP_HTTP_API void _http_build_url(const php_url *old_url, const php_url *new_url
        if (url->port) {
                if (    ((url->port == 80) && !strcmp(url->scheme, "http"))
                        ||      ((url->port ==443) && !strcmp(url->scheme, "https"))
-#if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
+#ifdef HTTP_HAVE_NETDB
                        ||      ((se = getservbyname(url->scheme, "tcp")) && se->s_port && 
                                        (url->port == ntohs(se->s_port)))
 #endif
index 66a7a9a..a3cb94f 100644 (file)
 
 #ifdef HTTP_WANT_NETDB
 #      ifdef PHP_WIN32
+#              define HTTP_HAVE_NETDB
 #              include <winsock2.h>
 #      elif defined(HAVE_NETDB_H)
+#              define HTTP_HAVE_NETDB
 #              include <netdb.h>
 #      endif
 #endif
@@ -93,7 +95,7 @@ ZEND_BEGIN_MODULE_GLOBALS(http)
        struct _http_globals_request {
                struct _http_globals_request_methods {
                        char *allowed;
-                       struct {
+                       struct _http_globals_request_methods_custom {
                                int count;
                                void *entries;
                        } custom;
index d4b13ac..df42ff6 100644 (file)
@@ -4,13 +4,12 @@ negotiation
 <?php
 include 'skip.inc';
 ?>
---ENV--
-HTTP_ACCEPT=application/xml, application/xhtml+xml, text/html ; q = .8
-HTTP_ACCEPT_LANGUAGE=de-AT,de-DE;q=0.8,en-GB;q=0.3,en-US;q=0.2
-HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7
 --FILE--
 <?php
 echo "-TEST\n";
+$_SERVER['HTTP_ACCEPT'] = 'application/xml, application/xhtml+xml, text/html ; q = .8';
+$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-AT,de-DE;q=0.8,en-GB;q=0.3,en-US;q=0.2';
+$_SERVER['HTTP_ACCEPT_CHARSET'] = 'ISO-8859-1,utf-8;q=0.7,*;q=0.7';
 $langs = array(
        array('de', 'en', 'es'),
 );
index 210f68d..1cc00de 100644 (file)
@@ -5,10 +5,9 @@ http_send_data() NIL-NUM range
 include 'skip.inc';
 checkcgi();
 ?>
---ENV--
-HTTP_RANGE=bytes=-5
 --FILE--
 <?php
+$_SERVER['HTTP_RANGE'] = 'bytes=-5';
 http_send_content_type('text/plain');
 http_send_data(str_repeat('123abc', 1000));
 ?>
index 3e982df..4e8f07b 100644 (file)
@@ -5,10 +5,9 @@ http_send_data() NUM-NUM range
 include 'skip.inc';
 checkcgi();
 ?>
---ENV--
-HTTP_RANGE=bytes=5-6
 --FILE--
 <?php
+$_SERVER['HTTP_RANGE'] = 'bytes=5-6';
 http_send_content_type('text/plain');
 http_send_data(str_repeat('123abc', 1000));
 ?>
index bbc8d78..87663fc 100644 (file)
@@ -5,10 +5,9 @@ http_send_data() NUM-NIL range
 include 'skip.inc';
 checkcgi();
 ?>
---ENV--
-HTTP_RANGE=bytes=5981-
 --FILE--
 <?php
+$_SERVER['HTTP_RANGE'] = 'bytes=5981-';
 http_send_content_type('text/plain');
 http_send_data(str_repeat('123abc', 1000));
 ?>
index 2cbb717..286c7e9 100644 (file)
@@ -5,10 +5,9 @@ http_send_data() oversized range
 include 'skip.inc';
 checkcgi();
 ?>
---ENV--
-HTTP_RANGE=bytes=5990-6000
 --FILE--
 <?php
+$_SERVER['HTTP_RANGE'] = 'bytes=5990-6000';
 http_send_content_type('text/plain');
 http_send_data(str_repeat('123abc', 1000));
 ?>
index 43d7a93..7771b8b 100644 (file)
@@ -9,6 +9,7 @@ checkcgi();
 HTTP_RANGE=bytes=0-3, 4-5,9-11
 --FILE--
 <?php
+$_SERVER['HTTP_RANGE'] = 'bytes=0-3, 4-5,9-11';
 http_send_content_type('text/plain');
 http_send_data(str_repeat('123abc', 1000));
 ?>
index d6705ea..b5287a3 100644 (file)
@@ -5,10 +5,9 @@ http_send_file() multiple ranges
 include 'skip.inc';
 checkcgi();
 ?>
---ENV--
-HTTP_RANGE=bytes=0-3, 4-5,9-11
 --FILE--
 <?php
+$_SERVER['HTTP_RANGE'] = 'bytes=0-3, 4-5,9-11';
 http_send_content_type('text/plain');
 http_send_file('data.txt');
 ?>
index bc157a9..3215b03 100644 (file)
@@ -6,10 +6,9 @@ include 'skip.inc';
 checkcgi();
 checkmin(5.1);
 ?>
---ENV--
-HTTP_RANGE=bytes=5-9
 --FILE--
 <?php
+$_SERVER['HTTP_RANGE'] = 'bytes=5-9';
 http_send_file('data.txt');
 ?>
 --EXPECTF--
index 20b853a..8ee6eac 100644 (file)
@@ -6,10 +6,9 @@ include 'skip.inc';
 checkcgi();
 checkmin(5.1);
 ?>
---ENV--
-HTTP_RANGE=bytes=-9
 --FILE--
 <?php
+$_SERVER['HTTP_RANGE'] = 'bytes=-9';
 http_send_file('data.txt');
 ?>
 --EXPECTF--
index 5ac521f..1012da4 100644 (file)
@@ -6,10 +6,9 @@ include 'skip.inc';
 checkcgi();
 checkmin(5.1);
 ?>
---ENV--
-HTTP_RANGE=bytes=1000-
 --FILE--
 <?php
+$_SERVER['HTTP_RANGE'] = 'bytes=1000- ';
 http_send_file('data.txt');
 ?>
 --EXPECTF--
index e97a091..1315488 100644 (file)
@@ -6,10 +6,9 @@ include 'skip.inc';
 checkcgi();
 checkmin(5.1);
 ?>
---ENV--
-HTTP_RANGE=bytes=-1111
 --FILE--
 <?php
+$_SERVER['HTTP_RANGE'] = 'bytes=-1111';
 http_send_file('data.txt');
 ?>
 --EXPECTF--