/* {{{ PHP_RINIT_FUNCTION */
PHP_RINIT_FUNCTION(http)
{
- http_globals_init(HTTP_GLOBALS);
+ http_globals_init(HTTP_G);
- if (HTTP_G(request).methods.allowed) {
- http_check_allowed_methods(HTTP_G(request).methods.allowed,
- strlen(HTTP_G(request).methods.allowed));
+ if (HTTP_G->request.methods.allowed) {
+ http_check_allowed_methods(HTTP_G->request.methods.allowed,
+ strlen(HTTP_G->request.methods.allowed));
}
if ( (SUCCESS != PHP_RINIT_CALL(http_request_method))
status = FAILURE;
}
- http_globals_free(HTTP_GLOBALS);
+ http_globals_free(HTTP_G);
return status;
}
/* }}} */
php_info_print_table_colspan_header(2, "Request Methods");
{
int i;
- getGlobals(G);
phpstr *custom_request_methods = phpstr_new();
phpstr *known_request_methods = phpstr_from_string(HTTP_KNOWN_METHODS, lenof(HTTP_KNOWN_METHODS));
- http_request_method_entry **ptr = G->request.methods.custom.entries;
+ http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
- for (i = 0; i < G->request.methods.custom.count; ++i) {
+ for (i = 0; i < HTTP_G->request.methods.custom.count; ++i) {
if (ptr[i]) {
phpstr_appendf(custom_request_methods, "%s, ", ptr[i]->name);
}
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(G->request.methods.allowed) ? G->request.methods.allowed : "(ANY)");
+ 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);
}
HTTP_LOG_WRITE(file, ident, message);
- HTTP_LOG_WRITE(HTTP_G(log).composite, ident, message);
+ HTTP_LOG_WRITE(HTTP_G->log.composite, ident, message);
}
/* }}} */
switch (status)
{
- case 301: http_log(HTTP_G(log).redirect, "301-REDIRECT", header); break;
- case 302: http_log(HTTP_G(log).redirect, "302-REDIRECT", header); break;
- case 303: http_log(HTTP_G(log).redirect, "303-REDIRECT", header); break;
- case 305: http_log(HTTP_G(log).redirect, "305-REDIRECT", header); break;
- case 307: http_log(HTTP_G(log).redirect, "307-REDIRECT", header); break;
- case 304: http_log(HTTP_G(log).cache, "304-CACHE", header); break;
- case 405: http_log(HTTP_G(log).allowed_methods, "405-ALLOWED", header); break;
+ case 301: http_log(HTTP_G->log.redirect, "301-REDIRECT", header); break;
+ case 302: http_log(HTTP_G->log.redirect, "302-REDIRECT", header); break;
+ case 303: http_log(HTTP_G->log.redirect, "303-REDIRECT", header); break;
+ case 305: http_log(HTTP_G->log.redirect, "305-REDIRECT", header); break;
+ case 307: http_log(HTTP_G->log.redirect, "307-REDIRECT", header); break;
+ case 304: http_log(HTTP_G->log.cache, "304-CACHE", header); break;
+ case 405: http_log(HTTP_G->log.allowed_methods, "405-ALLOWED", header); break;
default: http_log(NULL, header, body); break;
}
STR_FREE(header);
STR_FREE(body);
- if (HTTP_G(force_exit)) {
+ if (HTTP_G->force_exit) {
zend_bailout();
} else {
php_ob_set_internal_handler(http_ob_blackhole, 4096, "blackhole", 0 TSRMLS_CC);
*body = estrndup(*body, *length);
}
return SUCCESS;
- } else if (sapi_module.read_post && !HTTP_G(read_post_data)) {
+ } else if (sapi_module.read_post && !HTTP_G->read_post_data) {
char buf[4096];
int len;
- HTTP_G(read_post_data) = 1;
+ HTTP_G->read_post_data = 1;
while (0 < (len = sapi_module.read_post(buf, sizeof(buf) TSRMLS_CC))) {
*body = erealloc(*body, *length + len + 1);
if (SG(request_info).raw_post_data) {
s = php_stream_open_wrapper("php://input", "rb", 0, NULL);
- } else if (sapi_module.read_post && !HTTP_G(read_post_data)) {
- HTTP_G(read_post_data) = 1;
+ } else if (sapi_module.read_post && !HTTP_G->read_post_data) {
+ HTTP_G->read_post_data = 1;
if ((s = php_stream_temp_new())) {
char buf[4096];
return FAILURE;
}
- HTTP_G(etag).started = 1;
- return php_start_ob_buffer_named("ob_etaghandler", HTTP_G(send).buffer_size, 1 TSRMLS_CC);
+ HTTP_G->etag.started = 1;
+ return php_start_ob_buffer_named("ob_etaghandler", HTTP_G->send.buffer_size, 1 TSRMLS_CC);
}
PHP_HTTP_API zend_bool _http_interrupt_ob_etaghandler(TSRMLS_D)
{
- if (HTTP_G(etag).started) {
- HTTP_G(etag).started = 0;
- if (HTTP_G(etag).ctx) {
- efree(HTTP_G(etag).ctx);
- HTTP_G(etag).ctx = NULL;
+ if (HTTP_G->etag.started) {
+ HTTP_G->etag.started = 0;
+ if (HTTP_G->etag.ctx) {
+ efree(HTTP_G->etag.ctx);
+ HTTP_G->etag.ctx = NULL;
}
return 1;
}
*handled_output = estrndup(output, output_len);
/* are we supposed to run? */
- if (HTTP_G(etag).started) {
+ if (HTTP_G->etag.started) {
/* initialize the etag context */
if (mode & PHP_OUTPUT_HANDLER_START) {
- HTTP_G(etag).ctx = http_etag_init();
+ HTTP_G->etag.ctx = http_etag_init();
}
/* update */
- http_etag_update(HTTP_G(etag).ctx, output, output_len);
+ http_etag_update(HTTP_G->etag.ctx, output, output_len);
/* finish */
if (mode & PHP_OUTPUT_HANDLER_END) {
char *sent_header = NULL;
- char *etag = http_etag_finish(HTTP_G(etag).ctx);
+ char *etag = http_etag_finish(HTTP_G->etag.ctx);
- HTTP_G(etag).ctx = NULL;
+ HTTP_G->etag.ctx = NULL;
http_send_cache_control(HTTP_DEFAULT_CACHECONTROL, lenof(HTTP_DEFAULT_CACHECONTROL));
http_send_etag_ex(etag, strlen(etag), &sent_header);
PHP_RINIT_FUNCTION(http_encoding)
{
- getGlobals(G);
-
- if (G->send.inflate.start_auto) {
+ if (HTTP_G->send.inflate.start_auto) {
php_ob_set_internal_handler(_http_ob_inflatehandler, HTTP_INFLATE_BUFFER_SIZE, "http inflate", 0 TSRMLS_CC);
}
- if (G->send.deflate.start_auto) {
+ if (HTTP_G->send.deflate.start_auto) {
php_ob_set_internal_handler(_http_ob_deflatehandler, HTTP_DEFLATE_BUFFER_SIZE, "http deflate", 0 TSRMLS_CC);
}
return SUCCESS;
PHP_RSHUTDOWN_FUNCTION(http_encoding)
{
- getGlobals(G);
-
- if (G->send.deflate.stream) {
- http_encoding_deflate_stream_free((http_encoding_stream **) &G->send.deflate.stream);
+ if (HTTP_G->send.deflate.stream) {
+ http_encoding_deflate_stream_free((http_encoding_stream **) &HTTP_G->send.deflate.stream);
}
- if (G->send.inflate.stream) {
- http_encoding_inflate_stream_free((http_encoding_stream **) &G->send.inflate.stream);
+ if (HTTP_G->send.inflate.stream) {
+ http_encoding_inflate_stream_free((http_encoding_stream **) &HTTP_G->send.inflate.stream);
}
return SUCCESS;
}
{
if ( php_ob_handler_used("ob_gzhandler" TSRMLS_CC) ||
php_ob_handler_used("zlib output compression" TSRMLS_CC)) {
- HTTP_G(send).deflate.encoding = 0;
+ HTTP_G->send.deflate.encoding = 0;
} else {
- if (!HTTP_G(send).deflate.encoding) {
+ if (!HTTP_G->send.deflate.encoding) {
/* emit a content-length header */
if (content_length) {
char cl_header_str[128];
}
} else {
#ifndef HTTP_HAVE_ZLIB
- HTTP_G(send).deflate.encoding = 0;
+ HTTP_G->send.deflate.encoding = 0;
php_start_ob_buffer_named("ob_gzhandler", 0, 0 TSRMLS_CC);
#else
HashTable *selected;
add_next_index_stringl(&zsupported, "x-gzip", lenof("x-gzip"), 1);
add_next_index_stringl(&zsupported, "deflate", lenof("deflate"), 1);
- HTTP_G(send).deflate.encoding = 0;
+ HTTP_G->send.deflate.encoding = 0;
if ((selected = http_negotiate_encoding(&zsupported))) {
STATUS hs = FAILURE;
if (HASH_KEY_IS_STRING == zend_hash_get_current_key(selected, &encoding, &idx, 0) && encoding) {
if (!strcmp(encoding, "gzip") || !strcmp(encoding, "x-gzip")) {
if (SUCCESS == (hs = http_send_header_string("Content-Encoding: gzip"))) {
- HTTP_G(send).deflate.encoding = HTTP_ENCODING_GZIP;
+ HTTP_G->send.deflate.encoding = HTTP_ENCODING_GZIP;
}
} else if (!strcmp(encoding, "deflate")) {
if (SUCCESS == (hs = http_send_header_string("Content-Encoding: deflate"))) {
- HTTP_G(send).deflate.encoding = HTTP_ENCODING_DEFLATE;
+ HTTP_G->send.deflate.encoding = HTTP_ENCODING_DEFLATE;
}
}
if (SUCCESS == hs) {
}
zval_dtor(&zsupported);
- return HTTP_G(send).deflate.encoding;
+ return HTTP_G->send.deflate.encoding;
#endif
}
}
/* {{{ void http_ob_deflatehandler(char *, uint, char **, uint *, int) */
void _http_ob_deflatehandler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
{
- getGlobals(G);
-
*handled_output = NULL;
*handled_output_len = 0;
if (mode & PHP_OUTPUT_HANDLER_START) {
int flags;
- if (G->send.deflate.stream) {
+ if (HTTP_G->send.deflate.stream) {
zend_error(E_ERROR, "ob_deflatehandler() can only be used once");
return;
}
- G->send.deflate.encoding = !0;
+ HTTP_G->send.deflate.encoding = !0;
switch (http_encoding_response_start(0))
{
break;
}
- flags |= (G->send.deflate.start_flags &~ 0xf0);
- G->send.deflate.stream = http_encoding_deflate_stream_init(NULL, flags);
+ flags |= (HTTP_G->send.deflate.start_flags &~ 0xf0);
+ HTTP_G->send.deflate.stream = http_encoding_deflate_stream_init(NULL, flags);
}
- if (G->send.deflate.stream) {
- http_encoding_deflate_stream_update((http_encoding_stream *) G->send.deflate.stream, output, output_len, handled_output, handled_output_len);
+ if (HTTP_G->send.deflate.stream) {
+ http_encoding_deflate_stream_update((http_encoding_stream *) HTTP_G->send.deflate.stream, output, output_len, handled_output, handled_output_len);
if (mode & PHP_OUTPUT_HANDLER_END) {
char *remaining = NULL;
size_t remaining_len = 0;
- http_encoding_deflate_stream_finish((http_encoding_stream *) G->send.deflate.stream, &remaining, &remaining_len);
- http_encoding_deflate_stream_free((http_encoding_stream **) &G->send.deflate.stream);
+ http_encoding_deflate_stream_finish((http_encoding_stream *) HTTP_G->send.deflate.stream, &remaining, &remaining_len);
+ http_encoding_deflate_stream_free((http_encoding_stream **) &HTTP_G->send.deflate.stream);
if (remaining) {
*handled_output = erealloc(*handled_output, *handled_output_len + remaining_len + 1);
memcpy(*handled_output + *handled_output_len, remaining, remaining_len);
/* {{{ void http_ob_inflatehandler(char *, uint, char **, uint *, int) */
void _http_ob_inflatehandler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
{
- getGlobals(G);
-
*handled_output = NULL;
*handled_output_len = 0;
if (mode & PHP_OUTPUT_HANDLER_START) {
- if (G->send.inflate.stream) {
+ if (HTTP_G->send.inflate.stream) {
zend_error(E_ERROR, "ob_inflatehandler() can only be used once");
return;
}
- G->send.inflate.stream = http_encoding_inflate_stream_init(NULL, (HTTP_G(send).inflate.start_flags &~ 0xf0));
+ HTTP_G->send.inflate.stream = http_encoding_inflate_stream_init(NULL, (HTTP_G->send.inflate.start_flags &~ 0xf0));
}
- if (G->send.inflate.stream) {
- http_encoding_inflate_stream_update((http_encoding_stream *) G->send.inflate.stream, output, output_len, handled_output, handled_output_len);
+ if (HTTP_G->send.inflate.stream) {
+ http_encoding_inflate_stream_update((http_encoding_stream *) HTTP_G->send.inflate.stream, output, output_len, handled_output, handled_output_len);
if (mode & PHP_OUTPUT_HANDLER_END) {
char *remaining = NULL;
size_t remaining_len = 0;
- http_encoding_inflate_stream_finish((http_encoding_stream *) G->send.inflate.stream, &remaining, &remaining_len);
- http_encoding_inflate_stream_free((http_encoding_stream **) &G->send.inflate.stream);
+ http_encoding_inflate_stream_finish((http_encoding_stream *) HTTP_G->send.inflate.stream, &remaining, &remaining_len);
+ http_encoding_inflate_stream_free((http_encoding_stream **) &HTTP_G->send.inflate.stream);
if (remaining) {
*handled_output = erealloc(*handled_output, *handled_output_len + remaining_len + 1);
memcpy(*handled_output + *handled_output_len, remaining, remaining_len);
return;
}
- HTTP_G(send).throttle_delay = interval;
- HTTP_G(send).buffer_size = chunk_size;
+ HTTP_G->send.throttle_delay = interval;
+ HTTP_G->send.buffer_size = chunk_size;
}
/* }}} */
PHP_RINIT_FUNCTION(http_request_method)
{
- HTTP_G(request).methods.custom.entries = ecalloc(1, sizeof(http_request_method_entry *));
+ HTTP_G->request.methods.custom.entries = ecalloc(1, sizeof(http_request_method_entry *));
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(http_request_method)
{
int i;
- getGlobals(G);
- http_request_method_entry **ptr = G->request.methods.custom.entries;
+ http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
- for (i = 0; i < G->request.methods.custom.count; ++i) {
+ for (i = 0; i < HTTP_G->request.methods.custom.count; ++i) {
if (ptr[i]) {
http_request_method_unregister(HTTP_CUSTOM_REQUEST_METHOD_START + i);
}
}
- efree(G->request.methods.custom.entries);
+ efree(HTTP_G->request.methods.custom.entries);
return SUCCESS;
}
/* {{{ char *http_request_method_name(http_request_method) */
PHP_HTTP_API const char *_http_request_method_name(http_request_method m TSRMLS_DC)
{
- getGlobals(G);
- http_request_method_entry **ptr = G->request.methods.custom.entries;
+ http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
if (HTTP_STD_REQUEST_METHOD(m)) {
return http_request_methods[m];
}
if ( (HTTP_CUSTOM_REQUEST_METHOD(m) >= 0) &&
- (HTTP_CUSTOM_REQUEST_METHOD(m) < G->request.methods.custom.count) &&
+ (HTTP_CUSTOM_REQUEST_METHOD(m) < HTTP_G->request.methods.custom.count) &&
(ptr[HTTP_CUSTOM_REQUEST_METHOD(m)])) {
return ptr[HTTP_CUSTOM_REQUEST_METHOD(m)]->name;
}
PHP_HTTP_API int _http_request_method_exists(zend_bool by_name, http_request_method id, const char *name TSRMLS_DC)
{
int i;
- getGlobals(G);
- http_request_method_entry **ptr = G->request.methods.custom.entries;
+ http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
if (by_name) {
for (i = HTTP_MIN_REQUEST_METHOD; i < HTTP_MAX_REQUEST_METHOD; ++i) {
return i;
}
}
- for (i = 0; i < G->request.methods.custom.count; ++i) {
+ for (i = 0; i < HTTP_G->request.methods.custom.count; ++i) {
if (ptr[i] && !strcasecmp(name, ptr[i]->name)) {
return HTTP_CUSTOM_REQUEST_METHOD_START + i;
}
} else if (HTTP_STD_REQUEST_METHOD(id)) {
return id;
} else if ( (HTTP_CUSTOM_REQUEST_METHOD(id) >= 0) &&
- (HTTP_CUSTOM_REQUEST_METHOD(id) < G->request.methods.custom.count) &&
+ (HTTP_CUSTOM_REQUEST_METHOD(id) < HTTP_G->request.methods.custom.count) &&
(ptr[HTTP_CUSTOM_REQUEST_METHOD(id)])) {
return id;
}
{
int i, meth_num;
char *http_method, *method, *mconst;
- getGlobals(G);
- http_request_method_entry **ptr = G->request.methods.custom.entries;
+ http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
if (!isalpha(*method_name)) {
http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Request method does not start with a character (%s)", method_name);
method[method_name_len] = '\0';
mconst[method_name_len] = '\0';
- ptr = erealloc(ptr, sizeof(http_request_method_entry *) * (G->request.methods.custom.count + 1));
- G->request.methods.custom.entries = ptr;
- ptr[G->request.methods.custom.count] = emalloc(sizeof(http_request_method_entry));
- ptr[G->request.methods.custom.count]->name = method;
- ptr[G->request.methods.custom.count]->cnst = mconst;
- meth_num = HTTP_CUSTOM_REQUEST_METHOD_START + G->request.methods.custom.count++;
+ ptr = erealloc(ptr, sizeof(http_request_method_entry *) * (HTTP_G->request.methods.custom.count + 1));
+ HTTP_G->request.methods.custom.entries = ptr;
+ ptr[HTTP_G->request.methods.custom.count] = emalloc(sizeof(http_request_method_entry));
+ ptr[HTTP_G->request.methods.custom.count]->name = method;
+ ptr[HTTP_G->request.methods.custom.count]->cnst = mconst;
+ meth_num = HTTP_CUSTOM_REQUEST_METHOD_START + HTTP_G->request.methods.custom.count++;
method_name_len = spprintf(&http_method, 0, "HTTP_METH_%s", mconst);
zend_register_long_constant(http_method, method_name_len + 1, meth_num, CONST_CS, http_module_number TSRMLS_CC);
{
char *http_method;
int method_len;
- getGlobals(G);
- http_request_method_entry **ptr = G->request.methods.custom.entries;
+ http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
if (HTTP_STD_REQUEST_METHOD(method)) {
http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Standard request methods cannot be unregistered");
}
if ( (HTTP_CUSTOM_REQUEST_METHOD(method) < 0) ||
- (HTTP_CUSTOM_REQUEST_METHOD(method) > G->request.methods.custom.count) ||
+ (HTTP_CUSTOM_REQUEST_METHOD(method) > HTTP_G->request.methods.custom.count) ||
(!ptr[HTTP_CUSTOM_REQUEST_METHOD(method)])) {
http_error_ex(HE_NOTICE, HTTP_E_REQUEST_METHOD, "Custom request method with id %lu does not exist", method);
return FAILURE;
efree(ptr[HTTP_CUSTOM_REQUEST_METHOD(method)]->name);
efree(ptr[HTTP_CUSTOM_REQUEST_METHOD(method)]->cnst);
- STR_SET(ptr[HTTP_CUSTOM_REQUEST_METHOD(method)], NULL);
+ efree(ptr[HTTP_CUSTOM_REQUEST_METHOD(method)]);
+ ptr[HTTP_CUSTOM_REQUEST_METHOD(method)] = NULL;
return SUCCESS;
}
if (clean_ob) {
/* interrupt on-the-fly etag generation */
- HTTP_G(etag).started = 0;
+ HTTP_G->etag.started = 0;
/* discard previous output buffers */
php_end_ob_buffers(0 TSRMLS_CC);
}
{
zval *bsize_p, *bsize = convert_to_type_ex(IS_LONG, GET_STATIC_PROP(bufferSize), &bsize_p);
zval *delay_p, *delay = convert_to_type_ex(IS_DOUBLE, GET_STATIC_PROP(throttleDelay), &delay_p);
- HTTP_G(send).buffer_size = Z_LVAL_P(bsize);
- HTTP_G(send).throttle_delay = Z_DVAL_P(delay);
+ HTTP_G->send.buffer_size = Z_LVAL_P(bsize);
+ HTTP_G->send.throttle_delay = Z_DVAL_P(delay);
if (bsize_p) zval_ptr_dtor(&bsize_p);
if (delay_p) zval_ptr_dtor(&delay_p);
}
/* gzip */
- HTTP_G(send).deflate.encoding = zval_is_true(GET_STATIC_PROP(gzip));
+ HTTP_G->send.deflate.encoding = zval_is_true(GET_STATIC_PROP(gzip));
/* start ob */
- php_start_ob_buffer(NULL, HTTP_G(send).buffer_size, 0 TSRMLS_CC);
+ php_start_ob_buffer(NULL, HTTP_G->send.buffer_size, 0 TSRMLS_CC);
/* send */
switch (Z_LVAL_P(GET_STATIC_PROP(mode)))
#define HTTP_NANOSEC (1000 * 1000 * 1000)
#define HTTP_DIFFSEC (0.001)
- if (HTTP_G(send).throttle_delay >= HTTP_DIFFSEC) {
+ if (HTTP_G->send.throttle_delay >= HTTP_DIFFSEC) {
#if defined(PHP_WIN32)
- Sleep((DWORD) HTTP_MSEC(HTTP_G(send).throttle_delay));
+ Sleep((DWORD) HTTP_MSEC(HTTP_G->send.throttle_delay));
#elif defined(HAVE_USLEEP)
- usleep(HTTP_USEC(HTTP_G(send).throttle_delay));
+ usleep(HTTP_USEC(HTTP_G->send.throttle_delay));
#elif defined(HAVE_NANOSLEEP)
struct timespec req, rem;
- req.tv_sec = (time_t) HTTP_G(send).throttle_delay;
- req.tv_nsec = HTTP_NSEC(HTTP_G(send).throttle_delay) % HTTP_NANOSEC;
+ req.tv_sec = (time_t) HTTP_G->send.throttle_delay;
+ req.tv_nsec = HTTP_NSEC(HTTP_G->send.throttle_delay) % HTTP_NANOSEC;
while (nanosleep(&req, &rem) && (errno == EINTR) && (HTTP_NSEC(rem.tv_sec) + rem.tv_nsec) > HTTP_NSEC(HTTP_DIFFSEC))) {
req.tv_sec = rem.tv_sec;
#define http_send_response_data_plain(b, d, dl) _http_send_response_data_plain((b), (d), (dl) TSRMLS_CC)
static inline void _http_send_response_data_plain(void **buffer, const char *data, size_t data_len TSRMLS_DC)
{
- if (HTTP_G(send).deflate.encoding) {
+ if (HTTP_G->send.deflate.encoding) {
#ifdef HTTP_HAVE_ZLIB
char *encoded;
size_t encoded_len;
http_encoding_stream *s = *((http_encoding_stream **) buffer);
http_encoding_deflate_stream_update(s, data, data_len, &encoded, &encoded_len);
- phpstr_chunked_output((phpstr **) &s->storage, encoded, encoded_len, HTTP_G(send).buffer_size, _http_flush TSRMLS_CC);
+ phpstr_chunked_output((phpstr **) &s->storage, encoded, encoded_len, HTTP_G->send.buffer_size, _http_flush TSRMLS_CC);
efree(encoded);
#else
http_error(HE_ERROR, HTTP_E_RESPONSE, "Attempt to send GZIP response despite being able to do so; please report this bug");
#endif
} else {
- phpstr_chunked_output((phpstr **) buffer, data, data_len, HTTP_G(send).buffer_size, _http_flush TSRMLS_CC);
+ phpstr_chunked_output((phpstr **) buffer, data, data_len, HTTP_G->send.buffer_size, _http_flush TSRMLS_CC);
}
}
/* }}} */
#define http_send_response_finish(b) _http_send_response_finish((b) TSRMLS_CC)
static inline void _http_send_response_finish(void **buffer TSRMLS_DC)
{
- if (HTTP_G(send).deflate.encoding) {
+ if (HTTP_G->send.deflate.encoding) {
#ifdef HTTP_HAVE_ZLIB
char *encoded = NULL;
size_t encoded_len = 0;
efree(date);
/* remember */
- HTTP_G(send).last_modified = t;
+ HTTP_G->send.last_modified = t;
return ret;
}
char *etag_header;
if (!etag_len){
- http_error_ex(HE_WARNING, HTTP_E_HEADER, "Attempt to send empty ETag (previous: %s)\n", HTTP_G(send).unquoted_etag);
+ http_error_ex(HE_WARNING, HTTP_E_HEADER, "Attempt to send empty ETag (previous: %s)\n", HTTP_G->send.unquoted_etag);
return FAILURE;
}
/* remember */
- STR_SET(HTTP_G(send).unquoted_etag, estrndup(etag, etag_len));
+ STR_SET(HTTP_G->send.unquoted_etag, estrndup(etag, etag_len));
etag_len = spprintf(&etag_header, 0, "ETag: \"%s\"", etag);
status = http_send_header_string_ex(etag_header, etag_len, 1);
HTTP_CHECK_CONTENT_TYPE(content_type, return FAILURE);
/* remember for multiple ranges */
- STR_FREE(HTTP_G(send).content_type);
- HTTP_G(send).content_type = estrndup(content_type, ct_len);
+ STR_FREE(HTTP_G->send.content_type);
+ HTTP_G->send.content_type = estrndup(content_type, ct_len);
return http_send_header_ex("Content-Type", lenof("Content-Type"), content_type, ct_len, 1, NULL);
}
case RANGE_OK:
{
/* Range Request - only send ranges if entity hasn't changed */
- if ( http_match_etag_ex("HTTP_IF_MATCH", HTTP_G(send).unquoted_etag, 0) &&
- http_match_last_modified_ex("HTTP_IF_UNMODIFIED_SINCE", HTTP_G(send).last_modified, 0) &&
- http_match_last_modified_ex("HTTP_UNLESS_MODIFIED_SINCE", HTTP_G(send).last_modified, 0)) {
+ if ( http_match_etag_ex("HTTP_IF_MATCH", HTTP_G->send.unquoted_etag, 0) &&
+ http_match_last_modified_ex("HTTP_IF_UNMODIFIED_SINCE", HTTP_G->send.last_modified, 0) &&
+ http_match_last_modified_ex("HTTP_UNLESS_MODIFIED_SINCE", HTTP_G->send.last_modified, 0)) {
if (zend_hash_num_elements(&ranges) == 1) {
/* single range */
/* multi range */
HashPosition pos;
zval **range, **begin, **end;
- const char *content_type = HTTP_G(send).content_type;
+ const char *content_type = HTTP_G->send.content_type;
char boundary_str[32], range_header_str[256];
size_t boundary_len, range_header_len;
}
/* send 304 Not Modified if last modified matches */
- if (!no_cache && http_match_last_modified("HTTP_IF_MODIFIED_SINCE", HTTP_G(send).last_modified)) {
+ if (!no_cache && http_match_last_modified("HTTP_IF_MODIFIED_SINCE", HTTP_G->send.last_modified)) {
char *sent_header = NULL;
- http_send_last_modified_ex(HTTP_G(send).last_modified, &sent_header);
+ http_send_last_modified_ex(HTTP_G->send.last_modified, &sent_header);
return http_exit_ex(304, sent_header, NULL, 0);
}
# 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)
+# define HTTP_GET_REQUEST_TIME() HTTP_G->request_time
# endif
# include "SAPI.h"
#endif
#ifdef ZTS
# include "TSRM.h"
-# define HTTP_G(v) TSRMG(http_globals_id, zend_http_globals *, v)
-# define HTTP_GLOBALS ((zend_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(http_globals_id)])
+# define HTTP_G ((zend_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(http_globals_id)])
#else
-# define HTTP_G(v) (http_globals.v)
-# define HTTP_GLOBALS (&http_globals)
+# define HTTP_G (&http_globals)
#endif
-#define getGlobals(G) zend_http_globals *G = HTTP_GLOBALS
PHP_FUNCTION(http_test);
PHP_FUNCTION(http_date);
static inline void *_http_etag_init(TSRMLS_D)
{
void *ctx = NULL;
- char *mode = HTTP_G(etag).mode;
+ char *mode = HTTP_G->etag.mode;
#ifdef HTTP_HAVE_EXT_HASH
php_hash_ops *eho = NULL;
static inline char *_http_etag_finish(void *ctx TSRMLS_DC)
{
unsigned char digest[128] = {0};
- char *etag = NULL, *mode = HTTP_G(etag).mode;
+ char *etag = NULL, *mode = HTTP_G->etag.mode;
#ifdef HTTP_HAVE_EXT_HASH
php_hash_ops *eho = NULL;
#define http_etag_update(c, d, l) _http_etag_update((c), (d), (l) TSRMLS_CC)
static inline void _http_etag_update(void *ctx, const char *data_ptr, size_t data_len TSRMLS_DC)
{
- char *mode = HTTP_G(etag).mode;
+ char *mode = HTTP_G->etag.mode;
#ifdef HTTP_HAVE_EXT_HASH
php_hash_ops *eho = NULL;
#endif
#ifdef ZEND_ENGINE_2
# define HE_THROW E_THROW TSRMLS_CC
-# define HE_NOTICE (HTTP_G(only_exceptions) ? E_THROW : E_NOTICE) TSRMLS_CC
-# define HE_WARNING (HTTP_G(only_exceptions) ? E_THROW : E_WARNING) TSRMLS_CC
-# define HE_ERROR (HTTP_G(only_exceptions) ? E_THROW : E_ERROR) TSRMLS_CC
+# define HE_NOTICE (HTTP_G->only_exceptions ? E_THROW : E_NOTICE) TSRMLS_CC
+# define HE_WARNING (HTTP_G->only_exceptions ? E_THROW : E_WARNING) TSRMLS_CC
+# define HE_ERROR (HTTP_G->only_exceptions ? E_THROW : E_ERROR) TSRMLS_CC
#else
# define HE_THROW E_WARNING TSRMLS_CC
# define HE_NOTICE E_NOTICE TSRMLS_CC