#ifdef HTTP_HAVE_MHASH
# include <mhash.h>
#endif
+#ifdef HTTP_HAVE_ZLIB
+# include <zlib.h>
+#endif
#include <ctype.h>
PHP_FE(http_compress, NULL)
PHP_FE(http_uncompress, NULL)
#endif
+ PHP_FE(http_support, NULL)
EMPTY_FUNCTION_ENTRY
};
REGISTER_INI_ENTRIES();
- if (SUCCESS != http_headers_global_init()) {
- return FAILURE;
- }
- if (SUCCESS != http_cache_global_init()) {
- return FAILURE;
- }
- if (SUCCESS != http_request_method_global_init()) {
+ if ( (SUCCESS != http_support_global_init()) ||
+ (SUCCESS != http_headers_global_init()) ||
+ (SUCCESS != http_cache_global_init()) ||
+ (SUCCESS != http_request_method_global_init())) {
return FAILURE;
}
#ifdef HTTP_HAVE_CURL
#else
php_info_print_table_row(2, "cURL HTTP Requests", "disabled");
#endif
+#ifdef HTTP_HAVE_ZLIB
+ {
+ char my_zlib_version[64] = {0};
+
+ strlcat(my_zlib_version, "zlib/", 63);
+ strlcat(my_zlib_version, zlibVersion(), 63);
+ php_info_print_table_row(2, "zlib GZIP Encodings", my_zlib_version);
+ }
+#else
+ php_info_print_table_row(2, "zlib GZIP Encodings", "disabled");
+#endif
#ifdef HTTP_HAVE_MHASH
{
char mhash_info[32];
# ADD BSC32 /nologo\r
LINK32=link.exe\r
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386\r
-# ADD LINK32 libcurl.lib ssleay32.lib libeay32.lib zlib.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib wsock32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_http.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\curl\lib" /libpath:"..\..\..\php4\Release_TS" /libpath:"..\..\..\php4\Release_TS_Inline"\r
+# ADD LINK32 libmhash.lib libcurl.lib ssleay32.lib libeay32.lib zlib.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib wsock32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_http.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\curl\lib" /libpath:"..\..\..\php4\Release_TS" /libpath:"..\..\..\php4\Release_TS_Inline"\r
\r
!ELSEIF "$(CFG)" == "http - Win32 Debug_TS"\r
\r
# ADD BSC32 /nologo\r
LINK32=link.exe\r
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386\r
-# ADD LINK32 libcurl.lib ssleay32.lib libeay32.lib zlib.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib wsock32.lib /nologo /dll /machine:I386 /out:"..\..\Debug_TS/http.dll" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\php_build\curl\lib" /libpath:"..\..\..\php4\Release_TS" /libpath:"..\..\..\php4\Release_TS_Inline"\r
+# ADD LINK32 libmhash.lib libcurl.lib ssleay32.lib libeay32.lib zlib.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib wsock32.lib /nologo /dll /machine:I386 /out:"..\..\Debug_TS/http.dll" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\php_build\curl\lib" /libpath:"..\..\..\php4\Release_TS" /libpath:"..\..\..\php4\Release_TS_Inline"\r
\r
!ENDIF \r
\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\http_encoding_api.c\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\http_request_api.c\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\php_http_encoding_api.h\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\php_http_request_api.h\r
# End Source File\r
# Begin Source File\r
#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
ZEND_EXTERN_MODULE_GLOBALS(http);
+static zend_bool http_support_ssl;
+
+STATUS _http_support_global_init(INIT_FUNC_ARGS)
+{
+ http_support_ssl = http_request_supports_ssl();
+
+ HTTP_LONG_CONSTANT("HTTP_SUPPORT", HTTP_SUPPORT);
+ HTTP_LONG_CONSTANT("HTTP_SUPPORT_REQUESTS", HTTP_SUPPORT_REQUESTS);
+ HTTP_LONG_CONSTANT("HTTP_SUPPORT_MIMEMAGIC", HTTP_SUPPORT_MIMEMAGIC);
+ HTTP_LONG_CONSTANT("HTTP_SUPPORT_ENCODINGS", HTTP_SUPPORT_ENCODINGS);
+ HTTP_LONG_CONSTANT("HTTP_SUPPORT_MHASHETAGS", HTTP_SUPPORT_MHASHETAGS);
+ HTTP_LONG_CONSTANT("HTTP_SUPPORT_SSLREQUESTS", HTTP_SUPPORT_SSLREQUESTS);
+
+ return SUCCESS;
+}
+
+PHP_HTTP_API long _http_support(long feature)
+{
+ long support = HTTP_SUPPORT;
+
+#ifdef HTTP_HAVE_CURL
+ support |= HTTP_SUPPORT_REQUESTS;
+ if (http_support_ssl) {
+ support |= HTTP_SUPPORT_SSLREQUESTS;
+ }
+#endif
+#ifdef HTTP_HAVE_MHASH
+ support |= HTTP_SUPPORT_MHASHETAGS;
+#endif
+#ifdef HTTP_HAVE_MAGIC
+ support |= HTTP_SUPPORT_MIMEMAGIC;
+#endif
+#ifdef HTTP_HAVE_ZLIB
+ support |= HTTP_SUPPORT_ENCODINGS;
+#endif
+
+ if (feature) {
+ return (feature == (support & feature));
+ }
+ return support;
+}
+
/* char *pretty_key(char *, size_t, zend_bool, zend_bool) */
char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen)
{
#endif /* HTTP_HAVE_ZLIB */
/* }}} */
+/* {{{ proto int http_support([int feature = 0])
+ *
+ * Check for feature that require external libraries.
+ *
+ * Accpepts an optional in parameter specifying which feature to probe for.
+ * If the parameter is 0 or omitted, the return value contains a bitmask of
+ * all supported featuers that depend on external libraries.
+ *
+ * Available features to probe for are:
+ * - HTTP_SUPPORT: always set
+ * - HTTP_SUPPORT_REQUESTS: whether ext/http was linked against libcurl,
+ * and HTTP requests can be issued
+ * - HTTP_SUPPORT_SSLREQUESTS: whether libcurl was linked against openssl,
+ * and SSL requests can be issued
+ * - HTTP_SUPPORT_ENCOGINS: whether ext/http was linked against zlib,
+ * and compressed HTTP responses can be decoded
+ * - HTTP_SUPPORTS_MHASHETAGS: whether ext/http was linked against libhmash,
+ * and ETags can be generated with the available mhash algorithms
+ * - HTTP_SUPPORTS_MAGICMIME: whether ext/http was linked against libmagic,
+ * and the HttpResponse::guessContentType() method is usable
+ *
+ * Returns int, whether requested feature is supported, or a bitmask with
+ * all supported features.
+ */
+PHP_FUNCTION(http_support)
+{
+ long feature = 0;
+
+ RETVAL_LONG(0L);
+
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &feature)) {
+ RETVAL_LONG(http_support(feature));
+ }
+}
+/* }}} */
+
PHP_FUNCTION(http_test)
{
}
#endif /* HTTP_HAVE_CURL */
+zend_bool _http_request_supports_ssl(void)
+{
+#ifdef HTTP_NEED_SSL
+ return (zend_bool) 1;
+#else
+ return (zend_bool) 0;
+#endif
+}
+
/*
* Local variables:
* tab-width: 4
HTTP_ARG_VAL(encoded, 0)
HTTP_END_ARGS;
+HTTP_BEGIN_ARGS(support, 0)
+ HTTP_ARG_VAL(feature, 0)
+HTTP_END_ARGS;
+
zend_class_entry *http_util_object_ce;
zend_function_entry http_util_object_fe[] = {
HTTP_UTIL_ALIAS(date, http_date)
HTTP_UTIL_ALIAS(inflate, http_inflate)
HTTP_UTIL_ALIAS(compress, http_compress)
HTTP_UTIL_ALIAS(uncompress, http_uncompress)
+ HTTP_UTIL_ALIAS(support, http_support)
EMPTY_FUNCTION_ENTRY
};
</maintainers>
<release>
<version>0.15.0</version>
- <date>2005-10-05</date>
+ <date>2005-10-11</date>
<license>PHP License</license>
<state>beta</state>
- <notes>* Updated documentation
-* Renamed http_absolute_uri() to http_build_uri() (complements with http_build_query())
-* Changed the signature of the negotiator to fill the second parameter with the results array
+ <notes>+ Updated documentation (a lot)
++ Added optional third parameter to HttpRequest::__construct() accepting an array with options
++ Added compression functions gzencode/gzdecode, deflate/inflate, compress/uncompress
++ Added http_support() for probing features that depend on external libraries
+
+- Renamed http_absolute_uri() to http_build_uri() (complements with http_build_query())
+- Changed the signature of the negotiator to fill the second parameter with the results array
+
+* Fixed several ETag issues
+* Fixed HttpRequestPools detach() and attach() methods when the iterator is active
+* Fixed parsing messages with Content-Range headers
+* Fixed parsing messages with another Transfer-Encoding header value than chunked
</notes>
<deps>
<dep type="php" rel="ge" version="4.3"/>
<file role="test" name="data.txt"/>
<file role="test" name="date_001.phpt"/>
<file role="test" name="date_002.phpt"/>
+ <file role="test" name="etag_mode_001.phpt"/>
+ <file role="test" name="etag_mode_002.phpt"/>
+ <file role="test" name="etag_mode_003.phpt"/>
+ <file role="test" name="etag_mode_004.phpt"/>
+ <file role="test" name="etag_mode_011.phpt"/>
+ <file role="test" name="etag_mode_012.phpt"/>
+ <file role="test" name="etag_mode_013.phpt"/>
+ <file role="test" name="etag_mode_014.phpt"/>
+ <file role="test" name="etag_mode_crc.phpt"/>
<file role="test" name="get_request_data_001.phpt"/>
<file role="test" name="HttpMessage_001.phpt"/>
<file role="test" name="HttpRequestPool_001.phpt"/>
<file role="test" name="HttpRequest_003.phpt"/>
<file role="test" name="HttpResponse_001.phpt"/>
<file role="test" name="HttpResponse_002.phpt"/>
+ <file role="test" name="HttpResponse_003.phpt"/>
+ <file role="test" name="HttpResponse_004.phpt"/>
<file role="test" name="INI_001.phpt"/>
<file role="test" name="log.inc"/>
<file role="test" name="parse_headers_001.phpt"/>
<file role="test" name="redirect_002_logging.phpt"/>
<file role="test" name="redirect_003.phpt"/>
<file role="test" name="redirect_003_logging.phpt"/>
+ <file role="test" name="request_gzip.phpt"/>
<file role="test" name="send_data_001.phpt"/>
<file role="test" name="send_data_002.phpt"/>
<file role="test" name="send_data_003.phpt"/>
<file role="src" name="http_api.c"/>
<file role="src" name="http_cache_api.c"/>
<file role="src" name="http_date_api.c"/>
+ <file role="src" name="http_encoding_api.c"/>
<file role="src" name="http_exception_object.c"/>
<file role="src" name="http_functions.c"/>
<file role="src" name="http_headers_api.c"/>
<file role="src" name="php_http_api.h"/>
<file role="src" name="php_http_cache_api.h"/>
<file role="src" name="php_http_date_api.h"/>
+ <file role="src" name="php_http_encoding_api.h"/>
<file role="src" name="php_http_exception_object.h"/>
<file role="src" name="php_http_headers_api.h"/>
<file role="src" name="php_http_info_api.h"/>
+ Updated documentation (a lot)
+ Added optional third parameter to HttpRequest::__construct() accepting an array with options
+ Added compression functions gzencode/gzdecode, deflate/inflate, compress/uncompress
++ Added http_support() for probing features that depend on external libraries
- Renamed http_absolute_uri() to http_build_uri() (complements with http_build_query())
- Changed the signature of the negotiator to fill the second parameter with the results array
PHP_FUNCTION(http_compress);
PHP_FUNCTION(http_uncompress);
#endif
+PHP_FUNCTION(http_support);
PHP_MINIT_FUNCTION(http);
PHP_MSHUTDOWN_FUNCTION(http);
#include "php_http_std_defs.h"
#include "php_http_send_api.h"
+#define HTTP_SUPPORT 0x01L
+#define HTTP_SUPPORT_REQUESTS 0x02L
+#define HTTP_SUPPORT_MIMEMAGIC 0x04L
+#define HTTP_SUPPORT_ENCODINGS 0x08L
+#define HTTP_SUPPORT_MHASHETAGS 0x10L
+#define HTTP_SUPPORT_SSLREQUESTS 0x20L
+
+#define http_support_global_init() _http_support_global_init(INIT_FUNC_ARGS_PASSTHRU)
+extern STATUS _http_support_global_init(INIT_FUNC_ARGS);
+
+#define http_support(f) _http_support(f)
+PHP_HTTP_API long _http_support(long feature);
+
#define pretty_key(key, key_len, uctitle, xhyphen) _http_pretty_key(key, key_len, uctitle, xhyphen)
extern char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen);
#ifndef PHP_HTTP_REQUEST_API_H
#define PHP_HTTP_REQUEST_API_H
+
+#define http_request_supports_ssl() _http_request_supports_ssl()
+extern zend_bool _http_request_supports_ssl(void);
+
+
#ifdef HTTP_HAVE_CURL
#include "php_http_std_defs.h"
#ifdef PHP_WIN32
# include <winsock2.h>
#endif
-
#include <curl/curl.h>
#define http_request_global_init() _http_request_global_init(INIT_FUNC_ARGS_PASSTHRU)
PHP_METHOD(HttpUtil, inflate);
PHP_METHOD(HttpUtil, compress);
PHP_METHOD(HttpUtil, uncompress);
+PHP_METHOD(HttpUtil, support);
#endif
#endif