switch (value)
{
+ case HTTP_ETAG_CRC32:
+ ZEND_WRITE("HTTP_ETAG_CRC32", lenof("HTTP_ETAG_CRC32"));
+ break;
+
case HTTP_ETAG_SHA1:
ZEND_WRITE("HTTP_ETAG_SHA1", lenof("HTTP_ETAG_SHA1"));
break;
{
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, "Extended HTTP support", "enabled");
+ php_info_print_table_row(2, "Extension Version", HTTP_PEXT_VERSION);
#ifdef HTTP_HAVE_CURL
- php_info_print_table_row(2, "cURL HTTP Requests:", curl_version());
+ php_info_print_table_row(2, "cURL HTTP Requests", curl_version());
#else
- php_info_print_table_row(2, "cURL HTTP Requests:", "disabled");
+ php_info_print_table_row(2, "cURL HTTP Requests", "disabled");
#endif
#ifdef HTTP_HAVE_MHASH
{
char mhash_info[32];
snprintf(mhash_info, 32, "libmhash/%d", MHASH_API_VERSION);
- php_info_print_table_row(2, "mhash ETag Generator:", mhash_info);
+ php_info_print_table_row(2, "mhash ETag Generator", mhash_info);
}
#else
- php_info_print_table_row(2, "mhash ETag Generator:", "disabled");
+ php_info_print_table_row(2, "mhash ETag Generator", "disabled");
#endif
#if defined(HTTP_HAVE_MAGIC) && !defined(WONKY)
- php_info_print_table_row(2, "magic MIME Guessing:", "libmagic/unknown");
+ php_info_print_table_row(2, "magic MIME Guessing", "libmagic/unknown");
#else
- php_info_print_table_row(2, "magic MIME Guessing:", "disabled");
+ php_info_print_table_row(2, "magic MIME Guessing", "disabled");
#endif
- php_info_print_table_row(2, "Registered Classes:",
+ php_info_print_table_row(2, "Registered Classes",
#ifndef ZEND_ENGINE_2
"none"
#else
);
}
php_info_print_table_end();
+
+ php_info_print_table_start();
+ php_info_print_table_colspan_header(2, "Supported ETag Hash Algorithms");
+ {
+
+ php_info_print_table_row(2, "PHP", "CRC32, MD5, SHA1");
+#ifdef HTTP_HAVE_MHASH
+ {
+ phpstr *algos = phpstr_new();
+ int i, c = mhash_count();
+
+ for (i = 0; i <= c; ++i) {
+ const char *hash = mhash_get_hash_name_static(i);
+
+ if (hash) {
+ phpstr_appendf(algos, "%s, ", hash);
+ }
+ }
+ phpstr_fix(algos);
+ php_info_print_table_row(2, "MHASH", PHPSTR_VAL(algos));
+ phpstr_free(&algos);
+ }
+#else
+ php_info_print_table_row(2, "MHASH", "not available");
+#endif
+ }
+ php_info_print_table_end();
php_info_print_table_start();
+ php_info_print_table_colspan_header(2, "Request Methods");
{
unsigned i;
zval **custom_method;
phpstr_fix(known_request_methods);
phpstr_fix(custom_request_methods);
- php_info_print_table_row(2, "Known Request Methods:", PHPSTR_VAL(known_request_methods));
- php_info_print_table_row(2, "Custom Request Methods:",
+ 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)");
+
phpstr_free(&known_request_methods);
phpstr_free(&custom_request_methods);
}
#include "ext/standard/md5.h"
#include "ext/standard/sha1.h"
+#include "ext/standard/crc32.h"
#include "php_http_std_defs.h"
#include "php_http.h"
extern STATUS _http_cache_global_init(INIT_FUNC_ARGS);
typedef enum {
+ HTTP_ETAG_CRC32 = -3,
HTTP_ETAG_MD5 = -2,
HTTP_ETAG_SHA1 = -1,
} http_etag_mode;
switch (mode)
{
+ case HTTP_ETAG_CRC32:
+ ctx = emalloc(sizeof(unsigned int));
+ memset(ctx, 1, sizeof(unsigned int));
+ break;
+
case HTTP_ETAG_SHA1:
PHP_SHA1Init(ctx = emalloc(sizeof(PHP_SHA1_CTX)));
break;
switch (mode)
{
+ case HTTP_ETAG_CRC32:
+ *((unsigned int *) ctx) = ~*((unsigned int *) ctx);
+ etag = http_etag_digest((const unsigned char *) ctx, sizeof(unsigned int));
+ efree(ctx);
+ break;
+
case HTTP_ETAG_SHA1:
PHP_SHA1Final(digest, ctx);
etag = http_etag_digest(digest, 20);
{
switch (INI_INT("http.etag_mode"))
{
+ case HTTP_ETAG_CRC32:
+ {
+ unsigned int i, c = *((unsigned int *) ctx);
+
+ for (i = 0; i < data_len; ++i) {
+ c = CRC32(c, data_ptr[i]);
+ }
+ *((unsigned int *)ctx) = c;
+ }
+ break;
+
case HTTP_ETAG_SHA1:
PHP_SHA1Update(ctx, (const unsigned char *) data_ptr, data_len);
break;