#define http_globals_init(g) _http_globals_init((g) TSRMLS_CC)
static inline void _http_globals_init(zend_http_globals *G TSRMLS_DC)
{
- G->send.buffer_size = HTTP_SENDBUF_SIZE;
-#ifndef HTTP_HAVE_SAPI_RTIME
- G->request_time = time(NULL);
+#ifdef HTTP_HAVE_SAPI_RTIME
+ G->request.time = Z_LVAL_P(http_get_server_var("REQUEST_TIME"));
+#else
+ G->request.time = time(NULL);
#endif
+ G->send.buffer_size = HTTP_SENDBUF_SIZE;
G->read_post_data = 0;
}
struct tm nowtm;
char datetime[20] = {0};
- now = HTTP_GET_REQUEST_TIME();
+ now = HTTP_G->request.time;
strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", php_localtime_r(&now, &nowtm));
#define HTTP_LOG_WRITE(file, type, msg) \
if ((SUCCESS != zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void *) &hsv)) || (Z_TYPE_PP(hsv) != IS_ARRAY)) {
return NULL;
}
- if ((SUCCESS != zend_hash_find(Z_ARRVAL_PP(hsv), (char *) key, key_size, (void *) &var)) || (Z_TYPE_PP(var) != IS_STRING)) {
+ if ((SUCCESS != zend_hash_find(Z_ARRVAL_PP(hsv), (char *) key, key_size, (void *) &var))) {
return NULL;
}
- if (check && !(Z_STRVAL_PP(var) && Z_STRLEN_PP(var))) {
+ if (check && !((Z_TYPE_PP(var) == IS_STRING) && Z_STRVAL_PP(var) && Z_STRLEN_PP(var))) {
return NULL;
}
return *var;
php_stream_statbuf ssb;
switch (data_mode) {
- case SEND_DATA: return HTTP_GET_REQUEST_TIME();
+ case SEND_DATA: return HTTP_G->request.time;
case SEND_RSRC: return php_stream_stat((php_stream *) data_ptr, &ssb) ? 0 : ssb.sb.st_mtime;
default: return php_stream_stat_path((char *) data_ptr, &ssb) ? 0 : ssb.sb.st_mtime;
}
}
if (t == -1) {
- t = (long) HTTP_GET_REQUEST_TIME();
+ t = HTTP_G->request.time;
}
RETURN_STRING(http_date(t), 0);
}
if (t == -1) {
- t = (long) HTTP_GET_REQUEST_TIME();
+ t = HTTP_G->request.time;
}
RETURN_SUCCESS(http_send_last_modified(t));
// current time if not supplied (senseless though)
if (t == -1) {
- t = (long) HTTP_GET_REQUEST_TIME();
+ t = HTTP_G->request.time;
}
if (for_range) {
HTTP_CHECK_HEADERS_SENT(RETURN_FALSE);
- t = (long) HTTP_GET_REQUEST_TIME();
+ t = HTTP_G->request.time;
/* 0 or omitted */
if (!last_modified) {
/* {{{ proto bool http_cache_etag([string etag])
*
* Attempts to cache the sent entity by its ETag, either supplied or generated
- * by the hash algorithm specified by the INI setting "http.etag_mode".
+ * by the hash algorithm specified by the INI setting "http.etag.mode".
*
* If the clients "If-None-Match" header matches the supplied/calculated
* ETag, the body is considered cached on the clients side and
/* {{{ proto string ob_etaghandler(string data, int mode)
*
* For use with ob_start(). Output buffer handler generating an ETag with
- * the hash algorithm specified with the INI setting "http.etag_mode".
+ * the hash algorithm specified with the INI setting "http.etag.mode".
*/
PHP_FUNCTION(ob_etaghandler)
{
if (Z_LVAL_P(zoption) > 0) {
HTTP_CURL_OPT(CURLOPT_TIMEVALUE, Z_LVAL_P(zoption));
} else {
- HTTP_CURL_OPT(CURLOPT_TIMEVALUE, (long) HTTP_GET_REQUEST_TIME() + Z_LVAL_P(zoption));
+ HTTP_CURL_OPT(CURLOPT_TIMEVALUE, (long) HTTP_G->request.time + Z_LVAL_P(zoption));
}
HTTP_CURL_OPT(CURLOPT_TIMECONDITION, (long) (range_req ? CURL_TIMECOND_IFUNMODSINCE : CURL_TIMECOND_IFMODSINCE));
} else {
zval **data;
zend_hash_init(&methods, 0, NULL, ZVAL_PTR_DTOR, 0);
- http_parse_params(HTTP_G->request.methods.custom.ini, &methods);
+ http_parse_params(HTTP_G->request.methods.custom.ini, HTTP_PARAMS_DEFAULT, &methods);
FOREACH_HASH_VAL(pos, &methods, data) {
if (Z_TYPE_PP(data) == IS_STRING) {
http_request_method_register(Z_STRVAL_PP(data), Z_STRLEN_PP(data));
char boundary_str[32], range_header_str[256];
size_t boundary_len, range_header_len;
- boundary_len = snprintf(boundary_str, lenof(boundary_str), "%lu%0.9f", (ulong) HTTP_GET_REQUEST_TIME(), (float) php_combined_lcg(TSRMLS_C));
+ boundary_len = snprintf(boundary_str, lenof(boundary_str), "%lu%0.9f", (ulong) HTTP_G->request.time, (float) php_combined_lcg(TSRMLS_C));
range_header_len = snprintf(range_header_str, lenof(range_header_str), "Content-Type: multipart/byteranges; boundary=%s", boundary_str);
http_send_status_header_ex(206, range_header_str, range_header_len, 1);
#ifdef HTTP_WANT_SAPI
# if PHP_API_VERSION > 20041225
# define HTTP_HAVE_SAPI_RTIME
-# define HTTP_GET_REQUEST_TIME() sapi_get_request_time(TSRMLS_C)
# else
-# define HTTP_GET_REQUEST_TIME() HTTP_G->request_time
# endif
# include "SAPI.h"
#endif
} send;
struct _http_globals_request {
+ time_t time;
struct _http_globals_request_methods {
char *allowed;
struct _http_globals_request_methods_custom {
} methods;
} request;
-#ifndef HTTP_HAVE_SAPI_RTIME
- time_t request_time;
-#endif
#ifdef ZEND_ENGINE_2
zend_bool only_exceptions;
#endif
+++ /dev/null
---TEST--
-INI entries
---SKIPIF--
-<?php
-include 'skip.inc';
-?>
---FILE--
-<?php
-echo "-TEST\n";
-ini_set('http.cache_log', 'cache.log');
-var_dump(ini_get('http.cache_log'));
-ini_set('http.allowed_methods', 'POST, HEAD, GET');
-var_dump(ini_get('http.allowed_methods'));
-ini_set('http.only_exceptions', true);
-var_dump(ini_get('http.only_exceptions'));
-echo "Done\n";
-?>
---EXPECTF--
-%sTEST
-string(9) "cache.log"
-string(15) "POST, HEAD, GET"
-string(1) "1"
-Done
-
<?php
include 'log.inc';
log_prepare(_AMETH_LOG);
-ini_set('http.allowed_methods', 'POST');
+ini_set('http.request.methods.allowed', 'POST');
echo "Done\n";
?>
--EXPECTF--
<?php
include 'log.inc';
log_prepare(_AMETH_LOG);
-ini_set('http.allowed_methods', 'POST');
+ini_set('http.request.methods.allowed', 'POST');
echo "Done\n";
?>
--EXPECTF--
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'crc32');
+ini_set('http.etag.mode', 'crc32');
http_cache_etag();
http_send_data("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'sha1');
+ini_set('http.etag.mode', 'sha1');
http_cache_etag();
http_send_data("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'md5');
+ini_set('http.etag.mode', 'md5');
http_cache_etag();
http_send_data("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'sha256');
+ini_set('http.etag.mode', 'sha256');
http_cache_etag();
http_send_data("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'crc32');
+ini_set('http.etag.mode', 'crc32');
http_cache_etag();
print("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'sha1');
+ini_set('http.etag.mode', 'sha1');
http_cache_etag();
print("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'md5');
+ini_set('http.etag.mode', 'md5');
http_cache_etag();
print("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'sha256');
+ini_set('http.etag.mode', 'sha256');
http_cache_etag();
print("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', extension_loaded('hash')?'crc32b':'crc32');
+ini_set('http.etag.mode', extension_loaded('hash')?'crc32b':'crc32');
http_cache_etag();
http_send_data("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'SHA1');
+ini_set('http.etag.mode', 'SHA1');
http_cache_etag();
http_send_data("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'MD5');
+ini_set('http.etag.mode', 'MD5');
http_cache_etag();
http_send_data("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'sha256');
+ini_set('http.etag.mode', 'sha256');
http_cache_etag();
http_send_data("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', extension_loaded('hash')?'crc32b':'crc32');
+ini_set('http.etag.mode', extension_loaded('hash')?'crc32b':'crc32');
http_cache_etag();
print("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'SHA1');
+ini_set('http.etag.mode', 'SHA1');
http_cache_etag();
print("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'bogus');
+ini_set('http.etag.mode', 'bogus');
http_cache_etag();
print("abc\n");
?>
?>
--FILE--
<?php
-ini_set('http.etag_mode', 'sha256');
+ini_set('http.etag.mode', 'sha256');
http_cache_etag();
print("abc\n");
?>