- 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 a54036efdd8e8ab8e174ef6260dececfa7dcdd78..2bfd87630896889023bd94e9ef0af4f35318847e 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 0afce19355300457f472b613a18e99c9d47de18f..0d1c283557a9b7a57be24ec5c659754e3fb55b91 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 f5f66a7f846e599421edc7035669f15b3cd7dcb5..05244d18287a8080193a4e7d598bcdc87ae13cd3 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 517ee1aef43b924e8c0351ded1ce576f2da94c1c..6ca33514e7e640a9e8bc55ca76307f1c341f12da 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 66a7a9a33f5f05e6b2a1446d4ff5f525a95e9dfa..a3cb94f4083516e58fbe286d002b434ca39479a8 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 d4b13ac0ccc416d7def7c71df2830bd588a5e273..df42ff6c85f69b6c79a0e916783eccb3c89397b6 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 210f68d4fbcf2ab7faf0a814270f6104a10b0fd7..1cc00de3e6112dc05adf31f88b906ff6e604a7f5 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 3e982dffe87aa811a17ac2855015f702ec2fcc9d..4e8f07beda4c6a6ad9bb207b6864cdd961bce8df 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 bbc8d785b4ea72a0afd501157f5e8b31436bb60e..87663fcea9fb376c52176250e61ad50e9e41519d 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 2cbb71737428ede625411e2f1fe5326456e9e080..286c7e996896dbec3a0cde16a4a07e50282a87cf 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 43d7a93ca810d50e067b4b51b5aa21129f8f9e1e..7771b8b9e38714b6438841f7ea49ef3b1ac3d26d 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 d6705ea1f3101cddbf882c2a6b7accd4625c8a9b..b5287a37ac609cbd7dbf2ed1f5c6529abd51c286 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 bc157a95165fc08711eae3cfcf3acfee91648e09..3215b0393a5ecc22183a2ee66c3610c9bd1da0b4 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 20b853acea965dc02401fab9a21728beba552a09..8ee6eac645a378f944c0ed83383197244a4d0031 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 5ac521f8229901d100715274375f563c7f0fed35..1012da4784790f7cfcad59b9cf681ad180d3c9ae 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 e97a09157c810a639eb5ff421d9701081eded4ed..1315488102b109f7077469a72c3cf02089f3c674 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--