- 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 7176d2b033d41c8ab1d9153e4caf52458fffb4be..3b3dfddd8ce08a68af0d9b9dc3a714f97897c259 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 1c4a6a4e5cf19a746139019dfb5056a55803be83..0a7515744cfd5fefeba7ac7b36c9b0e1f37d7c21 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 a392801401de9cf2f77e437511dadfd44bd90bc6..0bb6cf22a9b6ae65a7f089cf902f64a406d2d44d 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 dab555238c98cfb82509f75d3d453e8967b7cf40..f8d1bf029fc396e22648b24c7ce3a75720848b67 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 3872009157a5d1ea3ace49c0c1a981a32de92ab0..91c16766aba994136783995584ccfcb27a77d341 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 9475a176b86c47cf1ee653c581b1234faeb415af..7b726c879b75938e45a18a74d0737bec5fa6c516 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 3fc2bc90eb01e3d891edf166f01b222891ba99bc..b6594bac3f98a952b1d2f5b21ac0342dfe2be951 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 fb44f026108972a26b3c3b6efb35ddab742d0309..444e3d067ffb530c829b820845f9ec139eab5ce9 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 aa495186e9b8aa72454214b188f4c762b0846bed..c094e640a56d11c918ed9e4d3156492a1286f78f 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 e8cfd6964000fe2381c13010a4f077fccb6de48f..c04664e9b486afd21ea5971309c7767ee52e1e96 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 dec76648b09613262cf01a3202cdb537e7c559c0..c544ccbe6bdac81b21c47b209527de7932554606 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 c28ff6f7945c8a152573cf0ea374f06c0c1e497e..b59dace58b583f3583cd712bcac5a377fdf54c91 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 fbe5fc2919d7f7784b18ce31ba55814ff5c0c743..f741e65754ea7bdeebe2976d9c9861ff985444c9 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 496a63ed8d4e735cf057dfaf5ac2307b6323877b..e9d39d7c0425ab7e8b5ac4495c6553249d32afb8 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 873d5b1df14341aa74432b2399bb688c04d74751..9e5c79a0c9be133c63ea940ceeff001708627223 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 43cf5a805ea0660905d66367f33493d81711383f..925cd6d06b5bf84f3e3f3507c190fd04a8fa37bb 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 c221f1ea0747ffe6a40e58309a4d4849b35e49fd..48c1cde8a2995bb1496e9192e8373549cce4c350 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 d9dfb40bd91faf71d0d1248bb8799aa9da5470a0..3a0c0200af8cd46e5da65384739f35600ef52a32 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 0d6cfa7cd59d2c150e7ab86a2c238c947fe0029e..5d46fa509c73c7efaf2c4ec9428b71cae0dd0640 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 d432b5cf65987974806c9c38be4266d1e9dce64f..8b2567437b625ce8af5035a67d9da404e910ad4d 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 9c35a5c4a989f906191c929ad522cbf865429db6..3fbf008e5329dfe63ac4e23f4086051be5e22f9e 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 2a8b469e346c092d1578bbb1828bac832632f5a0..b2fa5c54aa39bebab7d2c7b1c96d65033e281acb 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 bd6baeeaa21047b94df10913d061607ef9141d55..c949e5ee91f25fdc08910fd4a1c618ea7f2a136c 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 2f0eadedf7d4247a22be9a8692deb6a3d02da175..1801943a64d2488941343b6cb355c85d1e51bb38 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 3073ab4493f2115295a9efd82c812012a3ae7bbb..c6d08d20b95088da63f584ffd5a817f4ee4bfe4f 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 e349cc6cc3eb1a60c2b88fc3f53b17c4ff5cf96c..1a21dedfa84bd185687eb8250efc7fa1a1edc334 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 07912d8b8c7cb4306e132e790e30102ef6147d16..e25ad6fbed8ec6dfcd9b0cc1f57444409a000bc7 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 a87a8c6dfde985ae445e54408042970f1885b879..bc3e7da6504d050270b83fe6176422ea6fec6a03 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 19d7cdaa277141efb404d87bd48a0259ad4c8a12..478aa25686df8d3eb54f83f74e8abf24525531d6 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 d0839561dd32f4df6cf56cf1a5ca14a8bc9bfb85..a35fe07cfc1e37c16d3d38f4a3b66dae071fba11 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 31f430ddfb41e0bea6961c4229091ce7c9db6c69..3522685e3eac46dc83207cb0042145619aa9211f 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 e9c849474752d0915d46641a8d5d48dd770c4ef3..3a3dfe8da97e2d849e3c3a14947629587f475bb2 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 1c166a04ab4f2ea454f561feaf86b5a04611a79e..7d9a4c705cad0cdab54a9b94596216e869e65f62 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 67b3665b773ad7e541741b765d222426fc7e5bf1..88f79d53423c687c1832a42c35cc86d9e51896a8 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 7ae1fca1b75212ca609d4e99702f8a079c36bcf6..d1ffb7e3e04ab75a4e1b685fef3e6d69a76343e9 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 e9ea75cb8eafe00b90cda3b87180b7cc10ca5dd4..d1ab0b3d1ce4b26087ebc1fd9a49bd6c75f09a88 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 3d71e64571d9da67909c4dbbf99124f2f7a10197..c5af3be511b7c29bd488208e4a0050c9bd6b2fcc 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 4d6e54b752398f6f7b088e87ca5fd7f7f2e1bf88..5fd739c189c50bb9bcfda66ce9ba3e4cee0ee41d 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 9d79a2d49cd364d10ddaafb4387f4f5b90396949..29370b88f4d191a5d33279257b4778ddcece7787 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 4a4080f61acc890581505a759db03c921f0fd2c1..77e6ef0f4d7fb306bd4c209a5dc72bc0c993ba48 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 f0930adc7332bb8429b8d13ddddc8827aff251bc..bc9d31161f83b570d1e16c86133c78247a66904c 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