- module/includes cleanup
authorMichael Wallner <mike@php.net>
Tue, 22 Nov 2005 16:34:59 +0000 (16:34 +0000)
committerMichael Wallner <mike@php.net>
Tue, 22 Nov 2005 16:34:59 +0000 (16:34 +0000)
41 files changed:
config.m4
http.c
http_api.c
http_cache_api.c
http_date_api.c
http_encoding_api.c
http_exception_object.c
http_filter_api.c
http_functions.c
http_headers_api.c
http_info_api.c
http_message_api.c
http_message_object.c
http_request_api.c
http_request_method_api.c
http_request_object.c
http_request_pool_api.c
http_requestpool_object.c
http_response_object.c
http_send_api.c
http_url_api.c
http_util_object.c
package.xml
php_http.h
php_http_api.h
php_http_cache_api.h
php_http_date_api.h
php_http_encoding_api.h
php_http_exception_object.h
php_http_headers_api.h
php_http_message_api.h
php_http_message_object.h
php_http_request_api.h
php_http_request_method_api.h
php_http_request_object.h
php_http_request_pool_api.h
php_http_requestpool_object.h
php_http_response_object.h
php_http_send_api.h
php_http_url_api.h
tests/etag_mode_034.phpt

index 7176d2b..3b3dfdd 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -205,7 +205,7 @@ dnl ----
        PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
                php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
                php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
-               php_http_encoding_api.h phpstr/phpstr.h"
+               php_http_encoding_api.h phpstr/phpstr.h missing.h"
 
        ifdef([PHP_INSTALL_HEADERS], [
                PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
diff --git a/http.c b/http.c
index 1c4a6a4..0a75157 100644 (file)
--- a/http.c
+++ b/http.c
 
 /* $Id$ */
 
-
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
 
-#include "zend_extensions.h"
+#define HTTP_WANT_CURL
+#define HTTP_WANT_ZLIB
+#define HTTP_WANT_MAGIC
+#include "php_http.h"
 
 #include "SAPI.h"
 #include "php_ini.h"
 #include "ext/standard/info.h"
+#include "zend_extensions.h"
 
-#include "php_http.h"
-#include "php_http_std_defs.h"
 #include "php_http_api.h"
 #include "php_http_send_api.h"
 #include "php_http_cache_api.h"
 #include "php_http_headers_api.h"
+#include "php_http_message_api.h"
 #include "php_http_request_method_api.h"
 #ifdef HTTP_HAVE_CURL
 #      include "php_http_request_api.h"
 #      include "php_http_exception_object.h"
 #endif
 
-#include "missing.h"
-#include "phpstr/phpstr.h"
-
-#ifdef HTTP_HAVE_CURL
-#      ifdef PHP_WIN32
-#              include <winsock2.h>
-#      endif
-#      include <curl/curl.h>
-#endif
-#ifdef HTTP_HAVE_ZLIB
-#      include <zlib.h>
-#endif
-
-#include <ctype.h>
 
 ZEND_DECLARE_MODULE_GLOBALS(http);
 HTTP_DECLARE_ARG_PASS_INFO();
@@ -134,6 +121,9 @@ zend_function_entry http_functions[] = {
 static zend_module_dep http_module_dep[] = {
 #      ifdef HAVE_SPL
        ZEND_MOD_REQUIRED("spl")
+#      endif
+#      ifdef HTTP_HAVE_EXT_HASH
+       ZEND_MOD_REQUIRED("hash")
 #      endif
        {NULL, NULL, NULL, 0}
 };
@@ -155,7 +145,7 @@ zend_module_entry http_module_entry = {
        PHP_RINIT(http),
        PHP_RSHUTDOWN(http),
        PHP_MINFO(http),
-       HTTP_PEXT_VERSION,
+       PHP_EXT_HTTP_VERSION,
        STANDARD_MODULE_PROPERTIES
 };
 /* }}} */
@@ -315,7 +305,7 @@ PHP_MINFO_FUNCTION(http)
        php_info_print_table_start();
        {
                php_info_print_table_row(2, "Extended HTTP support", "enabled");
-               php_info_print_table_row(2, "Extension Version", HTTP_PEXT_VERSION);
+               php_info_print_table_row(2, "Extension Version", PHP_EXT_HTTP_VERSION);
 #ifdef HTTP_HAVE_CURL
                php_info_print_table_row(2, "cURL HTTP Requests", curl_version());
 #else
index a392801..0bb6cf2 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#include "php_http.h"
 
 #include "SAPI.h"
+#include "php_output.h"
 #include "ext/standard/url.h"
 #include "ext/standard/head.h"
 
-#include "php_http.h"
-#include "php_http_std_defs.h"
 #include "php_http_api.h"
-#include "php_http_headers_api.h"
-#include "php_http_request_api.h"
 #include "php_http_send_api.h"
 
 #ifdef ZEND_ENGINE_2
-#      include "zend_exceptions.h"
 #      include "php_http_exception_object.h"
 #endif
 
-#include <ctype.h>
-
-#ifdef HTTP_HAVE_MAGIC
-#      if defined(PHP_WIN32) && !defined(USE_MAGIC_DLL) && !defined(USE_MAGIC_STATIC)
-#              define USE_MAGIC_STATIC
-#      endif
-#      include <magic.h>
-#endif
-
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
 PHP_MINIT_FUNCTION(http_support)
@@ -337,63 +325,6 @@ PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_
 /* }}} */
 
 
-/* {{{ char *http_guess_content_type(char *magic_file, long magic_mode, void *data, size_t size, http_send_mode mode) */
-PHP_HTTP_API char *_http_guess_content_type(const char *magicfile, long magicmode, void *data_ptr, size_t data_len, http_send_mode data_mode TSRMLS_DC)
-{
-       char *ct = NULL;
-
-#ifdef HTTP_HAVE_MAGIC
-       /*      magic_load() fails if MAGIC_MIME is set because it 
-               cowardly adds .mime to the file name */
-       struct magic_set *magic = magic_open(magicmode &~ MAGIC_MIME);
-       
-       if (!magic) {
-               http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Invalid magic mode: %ld", magicmode);
-       } else if (-1 == magic_load(magic, magicfile)) {
-               http_error_ex(HE_WARNING, HTTP_E_RUNTIME, "Failed to load magic database '%s' (%s)", magicfile, magic_error(magic));
-       } else {
-               const char *ctype = NULL;
-               
-               magic_setflags(magic, magicmode);
-               
-               switch (data_mode)
-               {
-                       case SEND_RSRC:
-                       {
-                               char *buffer;
-                               size_t b_len;
-                               
-                               b_len = php_stream_copy_to_mem(data_ptr, &buffer, 65536, 0);
-                               ctype = magic_buffer(magic, buffer, b_len);
-                               efree(buffer);
-                       }
-                       break;
-                       
-                       case SEND_DATA:
-                               ctype = magic_buffer(magic, data_ptr, data_len);
-                       break;
-                       
-                       default:
-                               ctype = magic_file(magic, data_ptr);
-                       break;
-               }
-               
-               if (ctype) {
-                       ct = estrdup(ctype);
-               } else {
-                       http_error_ex(HE_WARNING, HTTP_E_RUNTIME, "Failed to guess Content-Type: %s", magic_error(magic));
-               }
-       }
-       if (magic) {
-               magic_close(magic);
-       }
-#else
-       http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot guess Content-Type; libmagic not available");
-#endif
-       
-       return ct;
-}
-/* }}} */
 /*
  * Local variables:
  * tab-width: 4
index dab5552..f8d1bf0 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#include "php_http.h"
 
 #include "SAPI.h"
-#include "php_streams.h"
 #include "php_output.h"
+#include "php_streams.h"
 
-#include "php_http.h"
-#include "php_http_std_defs.h"
 #include "php_http_api.h"
 #include "php_http_cache_api.h"
-#include "php_http_send_api.h"
 #include "php_http_date_api.h"
+#include "php_http_send_api.h"
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
index 3872009..91c1676 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
 
 #include "php_http.h"
-#include "php_http_std_defs.h"
-
-#include <ctype.h>
+#include "php_http_date_api.h"
 
 static int check_day(char *day, size_t len);
 static int check_month(char *month);
index 9475a17..7b726c8 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
-
-#include "php_http_encoding_api.h"
 #include "php_http.h"
-#include "php_http_api.h"
 
-#ifdef HTTP_HAVE_ZLIB
-#      include "php_http_send_api.h"
-#      include "php_http_headers_api.h"
-#      include <zlib.h>
-#endif
+#include "php_http_api.h"
+#include "php_http_encoding_api.h"
+#include "php_http_send_api.h"
+#include "php_http_headers_api.h"
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
index 3fc2bc9..b6594ba 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
 
-#ifdef ZEND_ENGINE_2
+#include "php_http.h"
 
-#include "zend_exceptions.h"
+#ifdef ZEND_ENGINE_2
 
-#include "php_http.h"
-#include "php_http_std_defs.h"
 #include "php_http_exception_object.h"
 
 #define HTTP_EX_DEF_CE http_exception_object_ce
index fb44f02..444e3d0 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#include "php_http.h"
 
 #ifdef ZEND_ENGINE_2
 
-#include "php_http_std_defs.h"
+#include "php_streams.h"
 #include "php_http_api.h"
 #include "php_http_filter_api.h"
 
-#include "phpstr/phpstr.h"
-
-#include "php_streams.h"
-
 PHP_MINIT_FUNCTION(http_filter)
 {
        php_stream_filter_register_factory("http.*", &http_filter_factory TSRMLS_CC);
index aa49518..c094e64 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
 
-#include "zend_operators.h"
+#define HTTP_WANT_CURL
+#include "php_http.h"
 
 #include "SAPI.h"
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "ext/standard/php_string.h"
+#include "zend_operators.h"
+
 #if defined(HAVE_PHP_SESSION) && !defined(COMPILE_DL_SESSION)
 #      include "ext/session/php_session.h"
 #endif
 
-#include "php_http.h"
-#include "php_http_std_defs.h"
 #include "php_http_api.h"
-#include "php_http_request_api.h"
 #include "php_http_cache_api.h"
-#include "php_http_request_method_api.h"
-#include "php_http_request_api.h"
 #include "php_http_date_api.h"
+#include "php_http_encoding_api.h"
 #include "php_http_headers_api.h"
 #include "php_http_message_api.h"
+#include "php_http_request_api.h"
+#include "php_http_request_method_api.h"
 #include "php_http_send_api.h"
 #include "php_http_url_api.h"
-#include "php_http_encoding_api.h"
-
-#include "phpstr/phpstr.h"
 
 ZEND_EXTERN_MODULE_GLOBALS(http)
 
index e8cfd69..c04664e 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
 
-#include "ext/standard/php_string.h"
+#include "php_http.h"
+
 #include "ext/standard/url.h"
+#include "ext/standard/php_string.h"
 
-#include "php_http.h"
-#include "php_http_std_defs.h"
 #include "php_http_api.h"
 #include "php_http_headers_api.h"
-#include "php_http_info_api.h"
-
-#include <ctype.h>
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
index dec7664..c544ccb 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
 
 #include "php_http.h"
+
 #include "php_http_api.h"
-#include "php_http_std_defs.h"
 #include "php_http_info_api.h"
 
-#include <ctype.h>
-
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
 PHP_HTTP_API void _http_info_default_callback(void **nothing, HashTable **headers, http_info *info TSRMLS_DC)
index c28ff6f..b59dace 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
 
+#define HTTP_WANT_CURL
 #include "php_http.h"
-#include "php_http_std_defs.h"
+
+#include "SAPI.h"
+
 #include "php_http_api.h"
-#include "php_http_message_api.h"
+#include "php_http_encoding_api.h"
 #include "php_http_headers_api.h"
-#include "php_http_send_api.h"
+#include "php_http_message_api.h"
 #include "php_http_request_api.h"
+#include "php_http_send_api.h"
 #include "php_http_url_api.h"
-#include "php_http_encoding_api.h"
-
-#include "phpstr/phpstr.h"
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
index fbe5fc2..f741e65 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#include "php_http.h"
 
 #ifdef ZEND_ENGINE_2
 
-#include "php_http.h"
 #include "php_http_api.h"
-#include "php_http_std_defs.h"
+#include "php_http_message_api.h"
 #include "php_http_message_object.h"
 #include "php_http_exception_object.h"
 
-#include "phpstr/phpstr.h"
-#include "missing.h"
-
 #ifndef WONKY
 #      include "zend_interfaces.h"
 #      if defined(HAVE_SPL)
index 496a63e..e9d39d7 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#define HTTP_WANT_CURL
+#include "php_http.h"
 
 #ifdef HTTP_HAVE_CURL
 
-#include "php_http.h"
-#include "php_http_std_defs.h"
 #include "php_http_api.h"
 #include "php_http_request_api.h"
 #include "php_http_request_method_api.h"
 #include "php_http_url_api.h"
+
 #ifdef ZEND_ENGINE_2
 #      include "php_http_request_object.h"
 #endif
 
-#include "phpstr/phpstr.h"
-
-#ifdef PHP_WIN32
-#      include <winsock2.h>
-#endif
-
-#include <curl/curl.h>
-
 /* {{{ cruft for thread safe SSL crypto locks */
 #if defined(ZTS) && defined(HTTP_HAVE_SSL)
 #      ifdef PHP_WIN32
@@ -1041,7 +1034,7 @@ static inline void _http_curl_defaults(CURL *ch)
        HTTP_CURL_OPT(FOLLOWLOCATION, 0);
        HTTP_CURL_OPT(UNRESTRICTED_AUTH, 0);
        HTTP_CURL_OPT(REFERER, NULL);
-       HTTP_CURL_OPT(USERAGENT, "PECL::HTTP/" HTTP_PEXT_VERSION " (PHP/" PHP_VERSION ")");
+       HTTP_CURL_OPT(USERAGENT, "PECL::HTTP/" PHP_EXT_HTTP_VERSION " (PHP/" PHP_VERSION ")");
        HTTP_CURL_OPT(HTTPHEADER, NULL);
        HTTP_CURL_OPT(COOKIE, NULL);
        HTTP_CURL_OPT(COOKIEFILE, NULL);
index 873d5b1..9e5c79a 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
 
+#define HTTP_WANT_CURL
 #include "php_http.h"
-#include "php_http_std_defs.h"
+
 #include "php_http_api.h"
+#include "php_http_request_api.h"
 #include "php_http_request_method_api.h"
-#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
+
+#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL) && !defined(WONKY)
 #      include "php_http_request_object.h"
 #endif
 
-#include "missing.h"
-#include "phpstr/phpstr.h"
-
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
 /* {{{ char *http_request_methods[] */
index 43cf5a8..925cd6d 100644 (file)
 
 /* $Id$ */
 
-
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#define HTTP_WANT_CURL
+#include "php_http.h"
 
 #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
 
 #include "zend_interfaces.h"
 
-#include "php_http_std_defs.h"
-#include "php_http_request_object.h"
-#include "php_http_request_api.h"
-#include "php_http_request_pool_api.h"
-#include "php_http.h"
 #include "php_http_api.h"
-#include "php_http_url_api.h"
+#include "php_http_exception_object.h"
 #include "php_http_message_api.h"
 #include "php_http_message_object.h"
-#include "php_http_exception_object.h"
-
-#include "missing.h"
-
-#ifdef PHP_WIN32
-#      include <winsock2.h>
-#endif
-#include <curl/curl.h>
+#include "php_http_request_api.h"
+#include "php_http_request_object.h"
+#include "php_http_request_pool_api.h"
+#include "php_http_url_api.h"
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
index c221f1e..48c1cde 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#define HTTP_WANT_CURL
+#include "php_http.h"
 
 #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
 
-#include "php_http.h"
-#include "php_http_std_defs.h"
 #include "php_http_api.h"
 #include "php_http_request_api.h"
-#include "php_http_request_pool_api.h"
 #include "php_http_request_object.h"
+#include "php_http_request_pool_api.h"
 #include "php_http_requestpool_object.h"
 
 #ifndef HTTP_DEBUG_REQPOOLS
index d9dfb40..3a0c020 100644 (file)
 
 /* $Id$ */
 
-
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#define HTTP_WANT_CURL
+#include "php_http.h"
 
 #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
 
-#include "php_http_std_defs.h"
+#include "zend_interfaces.h"
+
 #include "php_http_api.h"
-#include "php_http_requestpool_object.h"
-#include "php_http_request_pool_api.h"
-#include "php_http_request_object.h"
 #include "php_http_exception_object.h"
+#include "php_http_request_api.h"
+#include "php_http_request_object.h"
+#include "php_http_request_pool_api.h"
+#include "php_http_requestpool_object.h"
 
-#include "missing.h"
-
-#include "zend_interfaces.h"
 #if defined(HAVE_SPL) && !defined(WONKY)
 /* SPL doesn't install its headers */
 extern PHPAPI zend_class_entry *spl_ce_Countable;
 #endif
 
-#ifdef PHP_WIN32
-#      include <winsock2.h>
-#endif
-#include <curl/curl.h>
-
 #define HTTP_BEGIN_ARGS(method, req_args)      HTTP_BEGIN_ARGS_EX(HttpRequestPool, method, 0, req_args)
 #define HTTP_EMPTY_ARGS(method, ret_ref)       HTTP_EMPTY_ARGS_EX(HttpRequestPool, method, ret_ref)
 #define HTTP_REQPOOL_ME(method, visibility)    PHP_ME(HttpRequestPool, method, HTTP_ARGS(HttpRequestPool, method), visibility)
index 0d6cfa7..5d46fa5 100644 (file)
@@ -16,9 +16,9 @@
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
 
-#include "missing.h"
+#define HTTP_WANT_MAGIC
+#include "php_http.h"
 
 /* broken static properties in PHP 5.0 */
 #if defined(ZEND_ENGINE_2) && !defined(WONKY)
 #include "SAPI.h"
 #include "php_ini.h"
 
-#include "php_http.h"
 #include "php_http_api.h"
-#include "php_http_std_defs.h"
-#include "php_http_response_object.h"
-#include "php_http_exception_object.h"
-#include "php_http_send_api.h"
 #include "php_http_cache_api.h"
+#include "php_http_exception_object.h"
 #include "php_http_headers_api.h"
+#include "php_http_response_object.h"
+#include "php_http_send_api.h"
 
-#ifdef HTTP_HAVE_MAGIC
-#      include <magic.h>
-#endif
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
index d432b5c..8b25674 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#define HTTP_WANT_MAGIC
+#include "php_http.h"
 
 #include "SAPI.h"
 #include "php_streams.h"
 #include "ext/standard/php_lcg.h"
 
-#include "php_http.h"
-#include "php_http_std_defs.h"
 #include "php_http_api.h"
-#include "php_http_date_api.h"
-#include "php_http_send_api.h"
-#include "php_http_headers_api.h"
-#include "php_http_date_api.h"
 #include "php_http_cache_api.h"
+#include "php_http_date_api.h"
 #include "php_http_encoding_api.h"
+#include "php_http_headers_api.h"
+#include "php_http_send_api.h"
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
@@ -451,6 +450,64 @@ PHP_HTTP_API STATUS _http_send_stream_ex(php_stream *file, zend_bool close_strea
 }
 /* }}} */
 
+/* {{{ char *http_guess_content_type(char *magic_file, long magic_mode, void *data, size_t size, http_send_mode mode) */
+PHP_HTTP_API char *_http_guess_content_type(const char *magicfile, long magicmode, void *data_ptr, size_t data_len, http_send_mode data_mode TSRMLS_DC)
+{
+       char *ct = NULL;
+
+#ifdef HTTP_HAVE_MAGIC
+       /*      magic_load() fails if MAGIC_MIME is set because it 
+               cowardly adds .mime to the file name */
+       struct magic_set *magic = magic_open(magicmode &~ MAGIC_MIME);
+       
+       if (!magic) {
+               http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Invalid magic mode: %ld", magicmode);
+       } else if (-1 == magic_load(magic, magicfile)) {
+               http_error_ex(HE_WARNING, HTTP_E_RUNTIME, "Failed to load magic database '%s' (%s)", magicfile, magic_error(magic));
+       } else {
+               const char *ctype = NULL;
+               
+               magic_setflags(magic, magicmode);
+               
+               switch (data_mode)
+               {
+                       case SEND_RSRC:
+                       {
+                               char *buffer;
+                               size_t b_len;
+                               
+                               b_len = php_stream_copy_to_mem(data_ptr, &buffer, 65536, 0);
+                               ctype = magic_buffer(magic, buffer, b_len);
+                               efree(buffer);
+                       }
+                       break;
+                       
+                       case SEND_DATA:
+                               ctype = magic_buffer(magic, data_ptr, data_len);
+                       break;
+                       
+                       default:
+                               ctype = magic_file(magic, data_ptr);
+                       break;
+               }
+               
+               if (ctype) {
+                       ct = estrdup(ctype);
+               } else {
+                       http_error_ex(HE_WARNING, HTTP_E_RUNTIME, "Failed to guess Content-Type: %s", magic_error(magic));
+               }
+       }
+       if (magic) {
+               magic_close(magic);
+       }
+#else
+       http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot guess Content-Type; libmagic not available");
+#endif
+       
+       return ct;
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
index 9c35a5c..3fbf008 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#define HTTP_WANT_NETDB
+#include "php_http.h"
 
 #include "SAPI.h"
 #include "zend_ini.h"
 #include "php_output.h"
 #include "ext/standard/url.h"
 
-#include "php_http.h"
 #include "php_http_api.h"
 #include "php_http_url_api.h"
-#include "php_http_std_defs.h"
-
-#include "phpstr/phpstr.h"
-
-#ifdef PHP_WIN32
-#      include <winsock2.h>
-#elif defined(HAVE_NETDB_H)
-#      include <netdb.h>
-#endif
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
index 2a8b469..b2fa5c5 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-#include "php.h"
+
+#include "php_http.h"
 
 #ifdef ZEND_ENGINE_2
 
-#include "php_http.h"
-#include "php_http_std_defs.h"
 #include "php_http_util_object.h"
 
 #define HTTP_BEGIN_ARGS(method, req_args)              HTTP_BEGIN_ARGS_EX(HttpUtil, method, 0, req_args)
index bd6baee..c949e5e 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
-<package version="1.0" packagerversion="1.4.4">
+<package version="1.0" packagerversion="1.4.3">
  <name>pecl_http</name>
  <summary>Extended HTTP Support</summary>
  <description>* Building absolute URLs
   </maintainer>
   </maintainers>
  <release>
-  <version>0.18.1</version>
-  <date>2005-11-17</date>
+  <version>0.19.0</version>
+  <date>2005-11-21</date>
   <license>BSD, revised</license>
   <state>beta</state>
-  <notes>* Fixed build with PHP-4 and PHP-5.0
+  <notes>* Fixed bug in http_negotiate_*() when client sends spaces within accept headers
+
+- Removed support for ETag hashing through libmhash
+
++ Added http_negotiate_content_type()
   </notes>
   <deps>
    <dep type="php" rel="ge" version="4.3"/>
@@ -35,7 +39,6 @@
   </deps>
   <configureoptions>
    <configureoption name="with-http-curl-requests" default="yes" prompt="whether to enable cURL HTTP requests; specify libcurl directory"/>
-   <configureoption name="with-http-mhash-etags" default="yes" prompt="whether to enable mhash ETag generator; specify libmhash directory"/>
    <configureoption name="with-http-magic-mime" default="no" prompt="whether to enable response content type guessing; specify libmagic directory"/>
    <configureoption name="with-http-zlib-compression" default="yes" prompt="whether to enable support for gzencoded/deflated message bodies; specify zlib directory"/>
   </configureoptions>
@@ -84,7 +87,6 @@
     <file role="test" name="etag_mode_042.phpt"/>
     <file role="test" name="etag_mode_043.phpt"/>
     <file role="test" name="etag_mode_044.phpt"/>
-    <file role="test" name="etag_mode_crc.phpt"/>
     <file role="test" name="exceptions.phpt"/>
     <file role="test" name="get_request_data_001.phpt"/>
     <file role="test" name="HttpMessage_001.phpt"/>
index 2f0eade..1801943 100644 (file)
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define HTTP_PEXT_VERSION "0.18.1"
+#define PHP_EXT_HTTP_VERSION "0.19.0"
 
-/* make compile on Win32 */
-#ifdef HTTP_HAVE_CURL
+#include "php.h"
+#include "php_http_std_defs.h"
+#include "phpstr/phpstr.h"
+#include "missing.h"
+
+
+#ifdef HTTP_WANT_NETDB
+#      ifdef PHP_WIN32
+#              include <winsock2.h>
+#      elif defined(HAVE_NETDB_H)
+#              include <netdb.h>
+#      endif
+#endif
+
+#if defined(HTTP_WANT_CURL) && defined(HTTP_HAVE_CURL)
 #      ifdef PHP_WIN32
 #              include <winsock2.h>
 #      endif
 #      include <curl/curl.h>
 #endif
 
-#include "phpstr/phpstr.h"
+#if defined(HTTP_WANT_MAGIC) && defined(HTTP_HAVE_MAGIC)
+#      if defined(PHP_WIN32) && !defined(USE_MAGIC_DLL) && !defined(USE_MAGIC_STATIC)
+#              define USE_MAGIC_STATIC
+#      endif
+#      include <magic.h>
+#endif
+
+#if defined(HTTP_WANT_ZLIB) && defined(HTTP_HAVE_ZLIB)
+#      include <zlib.h>
+#endif
+
+#include <ctype.h>
 
 extern zend_module_entry http_module_entry;
 #define phpext_http_ptr &http_module_entry
index 3073ab4..c6d08d2 100644 (file)
@@ -15,9 +15,6 @@
 #ifndef PHP_HTTP_API_H
 #define PHP_HTTP_API_H
 
-#include "php_http_std_defs.h"
-#include "php_http_send_api.h"
-
 #define HTTP_SUPPORT                           0x01L
 #define HTTP_SUPPORT_REQUESTS          0x02L
 #define HTTP_SUPPORT_MAGICMIME         0x04L
@@ -108,12 +105,9 @@ extern STATUS _http_check_method_ex(const char *method, const char *methods);
 PHP_HTTP_API zval *_http_get_server_var_ex(const char *key, size_t key_size, zend_bool check TSRMLS_DC);
 
 #define http_get_request_body(b, l) _http_get_request_body_ex((b), (l), 1 TSRMLS_CC)
-#define http_get_Request_body_ex(b, l, d) _http_get_request_body_ex((b), (l), (d) TSRMLS_CC)
+#define http_get_request_body_ex(b, l, d) _http_get_request_body_ex((b), (l), (d) TSRMLS_CC)
 PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_bool dup TSRMLS_DC);
 
-#define http_guess_content_type(mf, mm, d, l, m) _http_guess_content_type((mf), (mm), (d), (l), (m) TSRMLS_CC)
-PHP_HTTP_API char *_http_guess_content_type(const char *magic_file, long magic_mode, void *data_ptr, size_t data_len, http_send_mode mode TSRMLS_DC);
-
 
 #define http_locate_body _http_locate_body
 static inline const char *_http_locate_body(const char *message)
@@ -182,7 +176,6 @@ static inline zval *_convert_to_type_ex(int type, zval *z, zval **p)
        return z;
 }
 
-
 #endif
 
 /*
index e349cc6..1a21ded 100644 (file)
 #ifndef PHP_HTTP_CACHE_API_H
 #define PHP_HTTP_CACHE_API_H
 
-#include "zend_ini.h"
+#include "php_http_send_api.h"
 
 #include "ext/standard/crc32.h"
 #include "ext/standard/sha1.h"
 #include "ext/standard/md5.h"
-
-#include "php_http_std_defs.h"
-#include "php_http.h"
-#include "php_http_api.h"
-#include "php_http_send_api.h"
-
 #if defined(HTTP_HAVE_EXT_HASH)
 #      include "php_hash.h"
 #elif defined(HTTP_HAVE_HASH_EXT_HASH)
index 07912d8..e25ad6f 100644 (file)
@@ -15,8 +15,6 @@
 #ifndef PHP_HTTP_DATE_API_H
 #define PHP_HTTP_DATE_API_H
 
-#include "php_http_std_defs.h"
-
 #define http_date(t) _http_date((t) TSRMLS_CC)
 PHP_HTTP_API char *_http_date(time_t t TSRMLS_DC);
 
index a87a8c6..bc3e7da 100644 (file)
 #ifndef PHP_HTTP_ENCODING_API_H
 #define PHP_HTTP_ENCODING_API_H
 
-#include "php_http_std_defs.h"
-
 #ifdef HTTP_HAVE_ZLIB
-#      include "phpstr/phpstr.h"
 #      include <zlib.h>
 #endif
 
index 19d7cda..478aa25 100644 (file)
@@ -16,6 +16,8 @@
 #define PHP_HTTP_EXCEPTION_OBJECT_H
 #ifdef ZEND_ENGINE_2
 
+#include "zend_exceptions.h"
+
 PHP_MINIT_FUNCTION(http_exception_object);
 
 extern zend_class_entry *http_exception_object_ce;
index d083956..a35fe07 100644 (file)
@@ -15,7 +15,6 @@
 #ifndef PHP_HTTP_HEADERS_API_H
 #define PHP_HTTP_HEADERS_API_H
 
-#include "php_http_std_defs.h"
 #include "php_http_info_api.h"
 
 #define HTTP_REDIRECT          302L
index 31f430d..3522685 100644 (file)
@@ -16,7 +16,6 @@
 #define PHP_HTTP_MESSAGE_API_H
 
 #include "php_http_info_api.h"
-#include "phpstr/phpstr.h"
 
 typedef enum {
        HTTP_MSG_NONE           = 0,
index e9c8494..3a3dfe8 100644 (file)
@@ -16,8 +16,6 @@
 #define PHP_HTTP_MESSAGE_OBJECT_H
 #ifdef ZEND_ENGINE_2
 
-#include "php_http_message_api.h"
-
 typedef struct {
        zend_object zo;
        http_message *message;
index 1c166a0..7d9a4c7 100644 (file)
 
 #ifdef HTTP_HAVE_CURL
 
-#include "php_http_std_defs.h"
 #include "php_http_request_method_api.h"
 
-#include "phpstr/phpstr.h"
-
-#ifdef PHP_WIN32
-#      include <winsock2.h>
-#endif
-#include <curl/curl.h>
-
 extern PHP_MINIT_FUNCTION(http_request);
 extern PHP_MSHUTDOWN_FUNCTION(http_request);
 
index 67b3665..88f79d5 100644 (file)
@@ -15,9 +15,6 @@
 #ifndef PHP_HTTP_REQUEST_METHOD_API_H
 #define PHP_HTTP_REQUEST_METHOD_API_H
 
-#include "php_http_std_defs.h"
-#include "phpstr/phpstr.h"
-
 typedef enum {
        HTTP_NO_REQUEST_METHOD  = 0,
        /* HTTP/1.1 */
index 7ae1fca..d1ffb7e 100644 (file)
 #ifdef HTTP_HAVE_CURL
 #ifdef ZEND_ENGINE_2
 
-#ifdef PHP_WIN32
-#      include <winsock2.h>
-#endif
-
-#include <curl/curl.h>
-
-#include "php_http_request_api.h"
 #include "php_http_request_pool_api.h"
-#include "phpstr/phpstr.h"
 
 typedef struct {
        zend_object zo;
index e9ea75c..d1ab0b3 100644 (file)
 #define PHP_HTTP_REQUEST_POOL_API_H
 #ifdef HTTP_HAVE_CURL
 
-#include "php_http_std_defs.h"
-#include "php_http_request_api.h"
-#include "phpstr/phpstr.h"
-
-#ifdef PHP_WIN32
-#      include <winsock2.h>
-#endif
-
-#include <curl/curl.h>
-
 typedef struct {
        CURLM *ch;
        zend_llist finished;
index 3d71e64..c5af3be 100644 (file)
 #ifdef HTTP_HAVE_CURL
 #ifdef ZEND_ENGINE_2
 
-#ifdef PHP_WIN32
-#      include <winsock2.h>
-#endif
-
-#include <curl/curl.h>
-
-#include "php_http_request_pool_api.h"
-
 typedef struct {
        zend_object zo;
        http_request_pool pool;
index 4d6e54b..5fd739c 100644 (file)
@@ -15,9 +15,6 @@
 #ifndef PHP_HTTP_RESPONSE_OBJECT_H
 #define PHP_HTTP_RESPONSE_OBJECT_H
 #ifdef ZEND_ENGINE_2
-
-#include "missing.h"
-
 #ifndef WONKY
 
 extern zend_class_entry *http_response_object_ce;
index 9d79a2d..29370b8 100644 (file)
 #ifndef PHP_HTTP_SEND_API_H
 #define PHP_HTTP_SEND_API_H
 
-#include "SAPI.h"
-#include "php_streams.h"
-#include "php_http_std_defs.h"
-
 typedef enum {
        SEND_DATA,
        SEND_RSRC
@@ -62,6 +58,9 @@ PHP_HTTP_API STATUS _http_send_ex(const void *data, size_t data_size, http_send_
 #define http_send_stream_ex(s, c, nc) _http_send_stream_ex((s), (c), (nc) TSRMLS_CC)
 PHP_HTTP_API STATUS _http_send_stream_ex(php_stream *s, zend_bool close_stream, zend_bool no_cache TSRMLS_DC);
 
+#define http_guess_content_type(mf, mm, d, l, m) _http_guess_content_type((mf), (mm), (d), (l), (m) TSRMLS_CC)
+PHP_HTTP_API char *_http_guess_content_type(const char *magic_file, long magic_mode, void *data_ptr, size_t data_len, http_send_mode mode TSRMLS_DC);
+
 #endif
 
 /*
index 4a4080f..77e6ef0 100644 (file)
@@ -15,8 +15,6 @@
 #ifndef PHP_HTTP_URL_API_H
 #define PHP_HTTP_URL_API_H
 
-#include "php_http_std_defs.h"
-
 #define http_absolute_uri(url) http_absolute_url(url)
 #define http_absolute_uri_ex(url, url_len, proto, proto_len, host, host_len, port) _http_absolute_url_ex((url), (url_len), (proto), (proto_len), (host), (host_len), (port) TSRMLS_CC)
 #define http_absolute_url(url) http_absolute_url_ex((url), strlen(url), NULL, 0, NULL, 0, 0)
index f0930ad..bc9d311 100644 (file)
@@ -14,11 +14,11 @@ http_cache_etag();
 http_send_data("abc\n");
 ?>
 --EXPECTF--
-Content-type: %s
 X-Powered-By: PHP/%s
 Cache-Control: private, must-revalidate, max-age=0
 Accept-Ranges: bytes
 ETag: "edeaaff3f1774ad2888673770c6d64097e391bc362d7d6fb34982ddf0efd18cb"
 Content-Length: 4
+Content-type: %s
 
 abc