2
0

Compare commits

..

No commits in common. "77f9f06c2a73319cf7c02e8538f2d49bb6bb8e33" and "10586541b506ec4a79d4a2bf6c9f80a88b60c2a4" have entirely different histories.

59 changed files with 336 additions and 1062 deletions

View File

@ -1,9 +0,0 @@
install_data(
'core__cached_html.lua',
'core.lua',
'core__xsendfile.lua',
'secdownload.lua',
'secdownload__secdownload.lua',
install_dir: lua_dir,
install_tag: 'runtime',
)

View File

@ -1,4 +0,0 @@
install_man(
'lighttpd2.8',
'lighttpd2-worker.8',
)

View File

@ -1 +0,0 @@
configure_file(output: 'config.h', configuration: conf_data)

View File

@ -45,7 +45,9 @@
# endif # endif
#endif #endif
#include <lighttpd/config.h> #ifdef HAVE_CONFIG_H
# include <lighttpd/config.h>
#endif
#define GLIB_DISABLE_DEPRECATION_WARNINGS #define GLIB_DISABLE_DEPRECATION_WARNINGS

View File

@ -1,7 +1,9 @@
#ifndef SYS_SOCKET_H #ifndef SYS_SOCKET_H
#define SYS_SOCKET_H #define SYS_SOCKET_H
#ifdef HAVE_CONFIG_H
#include <lighttpd/config.h> #include <lighttpd/config.h>
#endif
#ifdef _WIN32 #ifdef _WIN32
#ifndef FD_SETSIZE #ifndef FD_SETSIZE

View File

@ -84,11 +84,9 @@ LI_API void li_string_append_int(GString *dest, gint64 val);
LI_API void li_apr_sha1_base64(GString *dest, const GString *passwd); LI_API void li_apr_sha1_base64(GString *dest, const GString *passwd);
LI_API void li_apr_md5_crypt(GString *dest, const GString *password, const GString *salt); LI_API void li_apr_md5_crypt(GString *dest, const GString *password, const GString *salt);
/* dest can be empty if salt is invalid (in which case li_safe_crypt returns FALSE) */ LI_API void li_safe_crypt(GString *dest, const GString *password, const GString *salt);
LI_API gboolean li_safe_crypt(GString *dest, const GString *password, const GString *salt);
/* g_string_append_len is a macro, and g_string_append_len(s, GSTR_LEN(x)) doesn't work; build inline wrapper */ INLINE GString* _li_g_string_append_len(GString *s, const gchar *val, gssize len);
INLINE GString *li_g_string_append_len(GString *s, const gchar *val, gssize len);
INLINE void li_g_string_clear(GString *s); INLINE void li_g_string_clear(GString *s);
INLINE void li_g_string_free(gpointer data); INLINE void li_g_string_free(gpointer data);
@ -132,7 +130,7 @@ LI_API gboolean _li_set_sys_error(GError **error, const gchar *msg, const gchar
INLINE void li_path_append_slash(GString *path) { INLINE void li_path_append_slash(GString *path) {
if (path->len == 0 || path->str[path->len-1] != '/') if (path->len == 0 || path->str[path->len-1] != '/')
li_g_string_append_len(path, "/", 1); g_string_append_len(path, "/", 1);
} }
/** warning: This "GString" does not make sure that there is a terminating '\0', and you shouldn't modify the GString */ /** warning: This "GString" does not make sure that there is a terminating '\0', and you shouldn't modify the GString */
@ -144,8 +142,12 @@ INLINE GString li_const_gstring(const gchar *str, gsize len) {
return gs; return gs;
} }
INLINE GString* li_g_string_append_len(GString *s, const gchar *val, gssize len) { #ifndef g_string_append_len
return g_string_append_len(s, val, len); # define g_string_append_len _li_g_string_append_len
#endif
INLINE GString* _li_g_string_append_len(GString *s, const gchar *val, gssize len) {
return g_string_insert_len(s, -1, val, len);
} }
INLINE void li_g_string_clear(GString *s) { INLINE void li_g_string_clear(GString *s) {

View File

@ -1,3 +0,0 @@
inc_dir = include_directories('.', is_system: true)
subdir('lighttpd')

View File

@ -1,331 +0,0 @@
project(
'lighttpd',
'c',
default_options: [
'buildtype=debugoptimized',
'c_std=c99', # gnu99?
],
version: '2.0.0',
license: 'MIT',
)
libexec_dir = get_option('prefix') / get_option('libexecdir')
# include_dir = get_option('prefix') / get_option('includedir')
modules_dir = get_option('prefix') / get_option('libdir') / (meson.project_name() + '-' + meson.project_version())
lua_dir = get_option('prefix') / get_option('datadir') / 'lighttpd2/lua'
compiler = meson.get_compiler('c')
dep_not_found = dependency('', required: false)
if target_machine.system() == 'windows'
add_project_arguments(
'-DNVALGRIND',
language: 'c'
)
# link ws2_32 ?
# ... ?
endif
# ragel to compile parsers
ragel_bin = find_program('ragel')
ragel_gen = generator(
ragel_bin,
output: '@BASENAME@.c',
arguments: ['-C', '-T1', '-o', '@OUTPUT@', '@INPUT@'],
)
ragel_gen_t0 = generator(
ragel_bin,
output: '@BASENAME@.c',
arguments: ['-C', '-T0', '-o', '@OUTPUT@', '@INPUT@'],
)
add_project_arguments(
'-D_FILE_OFFSET_BITS=64',
'-D_LARGEFILE_SOURCE',
'-D_LARGE_FILES',
language: 'c',
)
conf_data = configuration_data()
conf_data.set_quoted('PACKAGE_VERSION', meson.project_version())
conf_data.set_quoted('PACKAGE_NAME', meson.project_name())
conf_data.set_quoted('DEFAULT_LIBEXECDIR', libexec_dir)
conf_data.set_quoted('DEFAULT_LIBDIR', modules_dir)
# if target_machine.system() == 'windows'
# conf_data.set_quoted('DEFAULT_LIBDIR', 'lib')
# endif
conf_data.set_quoted('DEFAULT_LUADIR', lua_dir)
dep_threads = dependency('threads')
dep_gthread = dependency('gthread-2.0', version: '>=2.16')
dep_gmodule = dependency('gmodule-2.0', version: '>=2.16')
# find libev manually
dep_ev = compiler.find_library(
'ev',
has_headers: 'ev.h',
)
if not compiler.has_function(
'ev_time',
prefix: '#include <ev.h>',
dependencies: dep_ev,
)
error('Missing ev_time() in libev')
endif
if get_option('lua')
dep_lua = dependency('lua5.1', 'lua-5.1', 'lua')
opt_dep_lua = dep_lua
conf_data.set10('HAVE_LUA_H', true)
else
dep_lua = disabler()
opt_dep_lua = dep_not_found
endif
if get_option('unwind')
dep_unwind = dependency('libunwind')
conf_data.set10('HAVE_LIBUNWIND', true)
endif
if get_option('openssl')
dep_openssl = dependency('openssl') # should find both ssl and crypto
else
dep_openssl = disabler()
endif
if get_option('gnutls')
dep_gnutls = dependency('gnutls')
else
dep_gnutls = disabler()
endif
if get_option('sni')
opt_dep_idn = declare_dependency(
compile_args: '-DUSE_SNI',
dependencies: dependency('libidn')
)
else
opt_dep_idn = dep_not_found
endif
if get_option('bzip2')
opt_dep_bzip2 = compiler.find_library(
'bz2',
has_headers: 'bzlib.h',
)
if not compiler.has_function(
'BZ2_bzCompressInit',
prefix: '#include <bzlib.h>',
dependencies: opt_dep_bzip2,
)
error('Found libbz2, but missing BZ2_bzCompressInit()')
endif
conf_data.set10('HAVE_BZIP', true)
else
opt_dep_bzip2 = dep_not_found
endif
if get_option('deflate') ## zlib/gzip??
opt_dep_zlib = dependency('zlib')
conf_data.set10('HAVE_ZLIB', true)
else
opt_dep_zlib = dep_not_found
endif
if opt_dep_bzip2.found() or opt_dep_zlib.found()
dep_deflate = declare_dependency(dependencies: [opt_dep_bzip2, opt_dep_zlib])
else
dep_deflate = disabler()
endif
warn_c_args = [
'-Wshadow',
'-W',
'-pedantic',
]
warn_link_args = []
if get_option('extra-warnings')
warn_c_args += [
'-Wmissing-declarations',
'-Wdeclaration-after-statement',
'-Wcast-align',
'-Wsign-compare',
'-Wnested-externs',
'-Wpointer-arith',
'-Wmissing-prototypes',
'-Wshadow',
'-Wno-pointer-sign',
'-Wformat-security',
]
endif
check_sys_includes = [
'inttypes.h',
'stddef.h',
'stdint.h',
'sys/mman.h',
'sys/resource.h',
'sys/sendfile.h',
'sys/types.h',
'sys/uio.h',
'sys/un.h',
'unistd.h',
]
if get_option('profiler')
check_sys_includes += ['execinfo.h']
add_project_arguments(
'-DWITH_PROFILER',
language: 'c'
)
endif
check_libc_functions = [
'getrlimit',
'gmtime_r',
'inet_aton',
'inet_ntop',
'localtime_r',
'madvise',
'mmap',
'posix_fadvise',
'sendfile',
'sendfile64',
'sendfilev',
'writev',
'accept4',
]
# run compiler/env checks
foreach sys_include: check_sys_includes
if compiler.has_header(sys_include)
conf_data.set10('HAVE_' + sys_include.underscorify().to_upper(), true)
endif
endforeach
foreach libc_function: check_libc_functions
if compiler.has_function(libc_function)
conf_data.set10('HAVE_' + libc_function.underscorify().to_upper(), true)
endif
endforeach
add_project_arguments(
compiler.get_supported_arguments(warn_c_args),
language: 'c'
)
add_project_link_arguments(
compiler.get_supported_link_arguments(warn_link_args),
language: 'c'
)
# manual libcrypt with crypt_r check
lib_crypt = compiler.find_library(
'crypt',
required: false,
has_headers: 'crypt.h',
)
if lib_crypt.found()
if compiler.has_function(
'crypt_r',
prefix: '#include <crypt.h>',
dependencies: lib_crypt,
)
conf_data.set10('HAVE_CRYPT_H', true)
conf_data.set10('HAVE_CRYPT_R', true)
else
error('Found libcrypt, but missing crypt_r')
endif
else
warning('Missing libcrypt, using crypt instead of crypt_r')
endif
# need libm for fmod in throttle.c
lib_m = compiler.find_library('m')
# IPv6 support is mandatory by default
if get_option('ipv6')
if compiler.has_type(
'struct sockaddr_in6',
prefix: [
'#include <sys/types.h>',
'#include <sys/socket.h>',
'#include <netinet/in.h>',
],
)
conf_data.set10('HAVE_IPV6', true)
else
error('Missing struct sockaddr_in6, needed for IPv6 support')
endif
endif
# auto detect 'struct sockaddr_storage' - should work fine without it.
if compiler.has_type(
'struct sockaddr_storage',
prefix: '#include <sys/socket.h>',
)
conf_data.set10('HAVE_SOCKADDR_STORAGE', true)
endif
if target_machine.system() == 'freebsd'
lib_kvm = compiler.find_library(
'kvm',
has_headers: 'kvm.h',
)
if not compiler.has_function(
'kvm_open',
prefix: '#include <kvm.h>',
dependencies: lib_kvm,
)
error('Found libkvm, but missing kvm_open')
endif
else
lib_kvm = dep_not_found
endif
main_deps = [
dep_threads,
dep_gthread,
dep_gmodule,
dep_ev,
]
subdir('contrib')
subdir('doc')
subdir('include')
subdir('src')
subdir('tests')
summary(
{
'libexec path': libexec_dir,
'modules path': modules_dir,
'lua plugin path': lua_dir,
},
section: 'Paths',
)
summary(
{
'lua': get_option('lua'),
'ipv6': get_option('ipv6'),
'config-parser': get_option('config-parser'),
'unwind': get_option('unwind'),
'openssl': get_option('openssl'),
'gnutls': get_option('gnutls'),
'sni': get_option('sni'),
'bzip2': get_option('bzip2'),
'deflate': get_option('deflate'),
'profiler': get_option('profiler'),
},
section: 'Features',
)
summary(
{
'detected libcrypt/crypt_r()': lib_crypt.found(),
'detected mmap()': conf_data.get('HAVE_MMAP', 0) == 1,
'detected writev()': conf_data.get('HAVE_WRITEV', 0) == 1,
'detected sendfile*()': (
conf_data.get('HAVE_SENDFILE', 0) == 1
or conf_data.get('HAVE_SENDFILE64', 0) == 1
or conf_data.get('HAVE_SENDFILEV', 0) == 1
),
},
section: 'Detected',
)

View File

@ -1,12 +0,0 @@
option('lua', type : 'boolean', value : true, description : 'Build with lua (5.1); extends core and other modules, and builds mod_lua')
option('ipv6', type : 'boolean', value : true, description : 'Build with IPv6 support')
option('config-parser', type : 'boolean', value : true, description : 'Build with standard config parser')
option('unwind', type : 'boolean', value : true, description : 'Build with (lib)unwind support in asserts to print backtraces')
option('openssl', type : 'boolean', value : true, description : 'Build mod_openssl')
option('gnutls', type : 'boolean', value : true, description : 'Build mod_gnutls')
option('sni', type : 'boolean', value : true, description : 'Build mod_openssl/mod_gnutls with SNI support')
option('bzip2', type : 'boolean', value : true, description : 'Build mod_deflate with bzip2 support')
option('deflate', type : 'boolean', value : true, description : 'Build mod_deflate with zlib (deflate) support')
option('extra-warnings', type : 'boolean', value : true, description : 'Build with extra warnings enabled')
# option('static', type : 'boolean', value : false, description : 'Build static lighttpd with all modules included')
option('profiler', type : 'boolean', value : false, description : 'Build with memory profiler')

View File

@ -93,7 +93,7 @@ GQuark li_angel_config_parser_error_quark(void) {
} }
action name { action name {
li_g_string_append_len(ctx->token_string, ctx->mark, fpc - ctx->mark); g_string_append_len(ctx->token_string, ctx->mark, fpc - ctx->mark);
return TK_NAME; return TK_NAME;
} }
@ -617,7 +617,7 @@ static gboolean op_execute(liValue **vresult, liConfigToken op, liValue *v1, liV
case LI_VALUE_STRING: case LI_VALUE_STRING:
switch (op) { switch (op) {
case TK_PLUS: case TK_PLUS:
li_g_string_append_len(v1->data.string, GSTR_LEN(v2->data.string)); g_string_append_len(v1->data.string, GSTR_LEN(v2->data.string));
*vresult = v1; *vresult = v1;
v1 = NULL; v1 = NULL;
break; break;

View File

@ -52,14 +52,14 @@ void li_log_write(liServer *srv, liLogLevel log_level, guint flags, const gchar
srv->log.last_ts = li_cur_ts; srv->log.last_ts = li_cur_ts;
} }
li_g_string_append_len(log_line, GSTR_LEN(log_ts)); g_string_append_len(log_line, GSTR_LEN(log_ts));
} }
va_start(ap, fmt); va_start(ap, fmt);
g_string_append_vprintf(log_line, fmt, ap); g_string_append_vprintf(log_line, fmt, ap);
va_end(ap); va_end(ap);
li_g_string_append_len(log_line, CONST_STR_LEN("\n")); g_string_append_len(log_line, CONST_STR_LEN("\n"));
fprintf(stderr, "%s", log_line->str); fprintf(stderr, "%s", log_line->str);
} }

View File

@ -1,36 +0,0 @@
src_angel_shared = [
'angel_log.c',
'angel_plugin.c',
'angel_plugin_core.c',
'angel_proc.c',
'angel_server.c',
'angel_value.c',
] + ragel_gen.process(
'angel_config_parser.rl',
)
lib_shared_angel = library(
'lighttpd-' + meson.project_version() + '-sharedangel',
src_angel_shared,
include_directories: inc_dir,
dependencies: [
main_deps,
],
link_with: lib_common,
install: true,
)
bin_angel = executable(
'lighttpd2',
'angel_main.c',
include_directories: inc_dir,
dependencies: [
main_deps,
],
link_with: [
lib_common,
lib_shared_angel,
],
install: true,
install_dir: get_option('sbindir')
)

View File

@ -575,8 +575,8 @@ static gboolean prepare_call_header(GString **pbuf,
if (!li_angel_data_write_int32(buf, fd_count, err)) return FALSE; if (!li_angel_data_write_int32(buf, fd_count, err)) return FALSE;
if (type != ANGEL_CALL_SEND_RESULT) { if (type != ANGEL_CALL_SEND_RESULT) {
li_g_string_append_len(buf, mod, mod_len); g_string_append_len(buf, mod, mod_len);
li_g_string_append_len(buf, action, action_len); g_string_append_len(buf, action, action_len);
} }
return TRUE; return TRUE;

View File

@ -20,19 +20,19 @@ static gboolean error_eof(GError **err, const gchar *info) {
gboolean li_angel_data_write_int32(GString *buf, gint32 i, GError **err) { gboolean li_angel_data_write_int32(GString *buf, gint32 i, GError **err) {
g_return_val_if_fail(err == NULL || *err == NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
li_g_string_append_len(buf, (const gchar*) &i, sizeof(i)); g_string_append_len(buf, (const gchar*) &i, sizeof(i));
return TRUE; return TRUE;
} }
gboolean li_angel_data_write_int64(GString *buf, gint64 i, GError **err) { gboolean li_angel_data_write_int64(GString *buf, gint64 i, GError **err) {
g_return_val_if_fail(err == NULL || *err == NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
li_g_string_append_len(buf, (const gchar*) &i, sizeof(i)); g_string_append_len(buf, (const gchar*) &i, sizeof(i));
return TRUE; return TRUE;
} }
gboolean li_angel_data_write_char (GString *buf, gchar c, GError **err) { gboolean li_angel_data_write_char (GString *buf, gchar c, GError **err) {
g_return_val_if_fail(err == NULL || *err == NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
li_g_string_append_len(buf, &c, sizeof(c)); g_string_append_len(buf, &c, sizeof(c));
return TRUE; return TRUE;
} }
@ -46,7 +46,7 @@ gboolean li_angel_data_write_str (GString *buf, const GString *str, GError **er
return FALSE; return FALSE;
} }
if (!li_angel_data_write_int32(buf, str->len, err)) return FALSE; if (!li_angel_data_write_int32(buf, str->len, err)) return FALSE;
li_g_string_append_len(buf, GSTR_LEN(str)); g_string_append_len(buf, GSTR_LEN(str));
return TRUE; return TRUE;
} }
@ -106,7 +106,7 @@ gboolean li_angel_data_read_mem (liAngelBuffer *buf, GString **val, gsize len,
} else { } else {
g_string_truncate(s, 0); g_string_truncate(s, 0);
} }
li_g_string_append_len(s, buf->data->str + buf->pos, len); g_string_append_len(s, buf->data->str + buf->pos, len);
buf->pos += len; buf->pos += len;
return TRUE; return TRUE;
} }

View File

@ -1,38 +0,0 @@
src_common = [
'angel_connection.c',
'angel_data.c',
'buffer.c',
'encoding.c',
'events.c',
'fetch.c',
'idlist.c',
'jobqueue.c',
'memcached.c',
'mempool.c',
'module.c',
'radix.c',
'sys_memory.c',
'sys_socket.c',
'tasklet.c',
'utils.c',
'value.c',
# 'value_impl.c', -- "templated", gets included in main and angel
'waitqueue.c',
] + ragel_gen.process('ip_parsers.rl')
if get_option('profiler')
src_common += ['profiler.c']
endif
lib_common = library(
'lighttpd-' + meson.project_version() + '-common',
src_common,
include_directories: inc_dir,
dependencies: [
main_deps,
dep_unwind,
lib_crypt,
lib_kvm,
],
install: true,
)

View File

@ -1,6 +1,5 @@
#include <lighttpd/module.h> #include <lighttpd/module.h>
#include <lighttpd/utils.h>
liModules *li_modules_new(gpointer main, const gchar *module_dir, gboolean module_resident) { liModules *li_modules_new(gpointer main, const gchar *module_dir, gboolean module_resident) {
liModules *m = g_slice_new(liModules); liModules *m = g_slice_new(liModules);
@ -78,9 +77,9 @@ liModule* li_module_load(liModules *mods, const gchar* name) {
/* temporary strings for mod_xyz_init and mod_xyz_free */ /* temporary strings for mod_xyz_init and mod_xyz_free */
m_init_str = g_string_new(name); m_init_str = g_string_new(name);
li_g_string_append_len(m_init_str, CONST_STR_LEN("_init")); g_string_append_len(m_init_str, CONST_STR_LEN("_init"));
m_free_str = g_string_new(name); m_free_str = g_string_new(name);
li_g_string_append_len(m_free_str, CONST_STR_LEN("_free")); g_string_append_len(m_free_str, CONST_STR_LEN("_free"));
if (!g_module_symbol(mod->module, m_init_str->str, (gpointer *)&m_init) if (!g_module_symbol(mod->module, m_init_str->str, (gpointer *)&m_init)
|| !g_module_symbol(mod->module, m_free_str->str, (gpointer *)&mod->free) || !g_module_symbol(mod->module, m_free_str->str, (gpointer *)&mod->free)

View File

@ -628,12 +628,12 @@ GString *li_sockaddr_to_string(liSocketAddress addr, GString *dest, gboolean sho
dest = g_string_sized_new(0); dest = g_string_sized_new(0);
else else
g_string_truncate(dest, 0); g_string_truncate(dest, 0);
li_g_string_append_len(dest, CONST_STR_LEN("unix:")); g_string_append_len(dest, CONST_STR_LEN("unix:"));
{ {
const char* path_start = saddr_up.un->sun_path; const char* path_start = saddr_up.un->sun_path;
const char* path_end = ((const char*)saddr_up.un) + addr.len; const char* path_end = ((const char*)saddr_up.un) + addr.len;
size_t path_len = path_end - path_start; size_t path_len = path_end - path_start;
li_g_string_append_len(dest, path_start, strnlen(path_start, path_len)); g_string_append_len(dest, path_start, strnlen(path_start, path_len));
} }
break; break;
#endif #endif
@ -807,7 +807,7 @@ gboolean li_string_prefix(const GString *str, const gchar *s, gsize len) {
GString *li_string_assign_len(GString *string, const gchar *val, gssize len) { GString *li_string_assign_len(GString *string, const gchar *val, gssize len) {
g_string_truncate(string, 0); g_string_truncate(string, 0);
li_g_string_append_len(string, val, len); g_string_append_len(string, val, len);
return string; return string;
} }
@ -902,7 +902,7 @@ void li_apr_sha1_base64(GString *dest, const GString *passwd) {
static void md5_crypt_to64(GString *dest, guint number, guint len) { static void md5_crypt_to64(GString *dest, guint number, guint len) {
static const gchar code[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; static const gchar code[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
for ( ; len-- > 0; ) { for ( ; len-- > 0; ) {
li_g_string_append_len(dest, code + (number & 63), 1); g_string_append_len(dest, code + (number & 63), 1);
number /= 64; number /= 64;
} }
} }
@ -979,9 +979,9 @@ void li_apr_md5_crypt(GString *dest, const GString *password, const GString *sal
} }
li_g_string_clear(dest); li_g_string_clear(dest);
li_g_string_append_len(dest, CONST_STR_LEN(APR1_MAGIC)); g_string_append_len(dest, CONST_STR_LEN(APR1_MAGIC));
li_g_string_append_len(dest, rsalt.str, rsalt.len); g_string_append_len(dest, rsalt.str, rsalt.len);
li_g_string_append_len(dest, CONST_STR_LEN("$")); g_string_append_len(dest, CONST_STR_LEN("$"));
md5_crypt_to64(dest, (digest[ 0] << 16) | (digest[ 6] << 8) | digest[12], 4); md5_crypt_to64(dest, (digest[ 0] << 16) | (digest[ 6] << 8) | digest[12], 4);
md5_crypt_to64(dest, (digest[ 1] << 16) | (digest[ 7] << 8) | digest[13], 4); md5_crypt_to64(dest, (digest[ 1] << 16) | (digest[ 7] << 8) | digest[13], 4);
md5_crypt_to64(dest, (digest[ 2] << 16) | (digest[ 8] << 8) | digest[14], 4); md5_crypt_to64(dest, (digest[ 2] << 16) | (digest[ 8] << 8) | digest[14], 4);
@ -990,23 +990,16 @@ void li_apr_md5_crypt(GString *dest, const GString *password, const GString *sal
md5_crypt_to64(dest, digest[11] , 2); md5_crypt_to64(dest, digest[11] , 2);
} }
gboolean li_safe_crypt(GString *dest, const GString *password, const GString *salt) { void li_safe_crypt(GString *dest, const GString *password, const GString *salt) {
g_string_truncate(dest, 0);
if (g_str_has_prefix(salt->str, "$apr1$")) { if (g_str_has_prefix(salt->str, "$apr1$")) {
li_apr_md5_crypt(dest, password, salt); li_apr_md5_crypt(dest, password, salt);
return TRUE;
} else { } else {
const char *crypt_res;
#ifdef HAVE_CRYPT_R #ifdef HAVE_CRYPT_R
struct crypt_data buffer; struct crypt_data buffer;
memset(&buffer, 0, sizeof(buffer)); memset(&buffer, 0, sizeof(buffer));
crypt_res = crypt_r(password->str, salt->str, &buffer); g_string_assign(dest, crypt_r(password->str, salt->str, &buffer));
if (NULL != crypt_res) {
g_string_assign(dest, crypt_res);
}
#else #else
/* This is an acceptable hack: any library that uses crypt() itself is "broken" /* This is an acceptable hack: any library that uses crypt() itself is "broken"
* for threaded usage anyway; and our own usage is protected. * for threaded usage anyway; and our own usage is protected.
@ -1014,13 +1007,9 @@ gboolean li_safe_crypt(GString *dest, const GString *password, const GString *sa
static GStaticMutex crypt_mutex = G_STATIC_MUTEX_INIT; static GStaticMutex crypt_mutex = G_STATIC_MUTEX_INIT;
g_static_mutex_lock(&crypt_mutex); g_static_mutex_lock(&crypt_mutex);
crypt_res = crypt(password->str, salt->str); g_string_assign(dest, crypt(password->str, salt->str));
if (NULL != crypt_res) {
g_string_assign(dest, crypt_res);
}
g_static_mutex_unlock(&crypt_mutex); g_static_mutex_unlock(&crypt_mutex);
#endif #endif
return crypt_res != NULL;
} }
} }

View File

@ -48,7 +48,7 @@ GString *li_common_value_to_string_(liValue *val) {
break; break;
case LI_VALUE_STRING: case LI_VALUE_STRING:
str = g_string_new_len(CONST_STR_LEN("\"")); str = g_string_new_len(CONST_STR_LEN("\""));
li_g_string_append_len(str, GSTR_LEN(val->data.string)); g_string_append_len(str, GSTR_LEN(val->data.string));
g_string_append_c(str, '"'); g_string_append_c(str, '"');
break; break;
case LI_VALUE_LIST: case LI_VALUE_LIST:
@ -59,7 +59,7 @@ GString *li_common_value_to_string_(liValue *val) {
g_string_free(tmp, TRUE); g_string_free(tmp, TRUE);
for (guint i = 1; i < val->data.list->len; i++) { for (guint i = 1; i < val->data.list->len; i++) {
tmp = li_value_to_string(g_ptr_array_index(val->data.list, i)); tmp = li_value_to_string(g_ptr_array_index(val->data.list, i));
li_g_string_append_len(str, CONST_STR_LEN(", ")); g_string_append_len(str, CONST_STR_LEN(", "));
g_string_append(str, tmp->str); g_string_append(str, tmp->str);
g_string_free(tmp, TRUE); g_string_free(tmp, TRUE);
} }

View File

@ -823,7 +823,7 @@ gboolean li_chunkqueue_extract_to(liChunkQueue *cq, goffset len, GString *dest,
gchar *buf; gchar *buf;
off_t we_have; off_t we_have;
if (LI_HANDLER_GO_ON != li_chunkiter_read(ci, coff, len, &buf, &we_have, err)) goto error; if (LI_HANDLER_GO_ON != li_chunkiter_read(ci, coff, len, &buf, &we_have, err)) goto error;
li_g_string_append_len(dest, buf, we_have); g_string_append_len(dest, buf, we_have);
coff += we_have; coff += we_have;
len -= we_have; len -= we_have;
if (len <= 0) return TRUE; if (len <= 0) return TRUE;

View File

@ -74,7 +74,7 @@ gboolean li_chunk_extract_to(liChunkParserMark from, liChunkParserMark to, GStri
dest->len += we_have; dest->len += we_have;
dest->str[dest->len] = '\0'; dest->str[dest->len] = '\0';
} else { } else {
li_g_string_append_len(dest, buf, we_have); g_string_append_len(dest, buf, we_have);
} }
i.pos += we_have; i.pos += we_have;
} }
@ -90,7 +90,7 @@ gboolean li_chunk_extract_to(liChunkParserMark from, liChunkParserMark to, GStri
dest->len += we_have; dest->len += we_have;
dest->str[dest->len] = '\0'; dest->str[dest->len] = '\0';
} else { } else {
li_g_string_append_len(dest, buf, we_have); g_string_append_len(dest, buf, we_have);
} }
i.pos += we_have; i.pos += we_have;
} }

View File

@ -141,7 +141,7 @@ GQuark li_config_error_quark(void) {
} }
action name { action name {
li_g_string_append_len(ctx->token_string, ctx->mark, fpc - ctx->mark); g_string_append_len(ctx->token_string, ctx->mark, fpc - ctx->mark);
return TK_NAME; return TK_NAME;
} }
@ -824,7 +824,7 @@ static gboolean op_execute(liValue **vresult, liConfigToken op, liValue *v1, liV
case LI_VALUE_STRING: case LI_VALUE_STRING:
switch (op) { switch (op) {
case TK_PLUS: case TK_PLUS:
li_g_string_append_len(v1->data.string, GSTR_LEN(v2->data.string)); g_string_append_len(v1->data.string, GSTR_LEN(v2->data.string));
*vresult = v1; *vresult = v1;
v1 = NULL; v1 = NULL;
break; break;

View File

@ -125,9 +125,9 @@ GString* li_lua_print_get_string(lua_State *L, int from, int to) {
if (0 == len) continue; if (0 == len) continue;
if (buf->len > 0) { if (buf->len > 0) {
g_string_append_c(buf, ' '); g_string_append_c(buf, ' ');
li_g_string_append_len(buf, s, len); g_string_append_len(buf, s, len);
} else { } else {
li_g_string_append_len(buf, s, len); g_string_append_len(buf, s, len);
} }
} }
lua_pop(L, 1); lua_pop(L, 1);

View File

@ -143,8 +143,8 @@ void li_environment_dup2cgi(liVRequest *vr, liEnvironmentDup *envdup, liAddEnvir
add_env_var(envdup, callback, param, CONST_STR_LEN("PATH_INFO"), GSTR_LEN(vr->physical.pathinfo)); add_env_var(envdup, callback, param, CONST_STR_LEN("PATH_INFO"), GSTR_LEN(vr->physical.pathinfo));
if (vr->physical.pathinfo->len) { if (vr->physical.pathinfo->len) {
g_string_truncate(tmp, 0); g_string_truncate(tmp, 0);
li_g_string_append_len(tmp, GSTR_LEN(vr->physical.doc_root)); /* TODO: perhaps an option for alternative doc-root? */ g_string_append_len(tmp, GSTR_LEN(vr->physical.doc_root)); /* TODO: perhaps an option for alternative doc-root? */
li_g_string_append_len(tmp, GSTR_LEN(vr->physical.pathinfo)); g_string_append_len(tmp, GSTR_LEN(vr->physical.pathinfo));
add_env_var(envdup, callback, param, CONST_STR_LEN("PATH_TRANSLATED"), GSTR_LEN(tmp)); add_env_var(envdup, callback, param, CONST_STR_LEN("PATH_TRANSLATED"), GSTR_LEN(tmp));
} }
@ -184,9 +184,9 @@ void li_environment_dup2cgi(liVRequest *vr, liEnvironmentDup *envdup, liAddEnvir
const GString hkey = li_const_gstring(h->data->str, h->keylen); const GString hkey = li_const_gstring(h->data->str, h->keylen);
g_string_truncate(tmp, 0); g_string_truncate(tmp, 0);
if (!li_strncase_equal(&hkey, CONST_STR_LEN("CONTENT-TYPE"))) { if (!li_strncase_equal(&hkey, CONST_STR_LEN("CONTENT-TYPE"))) {
li_g_string_append_len(tmp, CONST_STR_LEN("HTTP_")); g_string_append_len(tmp, CONST_STR_LEN("HTTP_"));
} }
li_g_string_append_len(tmp, h->data->str, h->keylen); g_string_append_len(tmp, h->data->str, h->keylen);
cgi_fix_header_name(tmp); cgi_fix_header_name(tmp);
add_env_var(envdup, callback, param, GSTR_LEN(tmp), h->data->str + h->keylen+2, h->data->len - (h->keylen+2)); add_env_var(envdup, callback, param, GSTR_LEN(tmp), h->data->str + h->keylen+2, h->data->len - (h->keylen+2));

View File

@ -123,9 +123,9 @@ void li_etag_mutate(GString *mut, GString *etag) {
for (h=0, i=0; i < etag->len; ++i) h = (h<<5)^(h>>27)^(etag->str[i]); for (h=0, i=0; i < etag->len; ++i) h = (h<<5)^(h>>27)^(etag->str[i]);
g_string_truncate(mut, 0); g_string_truncate(mut, 0);
li_g_string_append_len(mut, CONST_STR_LEN("\"")); g_string_append_len(mut, CONST_STR_LEN("\""));
li_string_append_int(mut, (guint64) h); li_string_append_int(mut, (guint64) h);
li_g_string_append_len(mut, CONST_STR_LEN("\"")); g_string_append_len(mut, CONST_STR_LEN("\""));
} }
void li_etag_set_header(liVRequest *vr, struct stat *st, gboolean *cachable) { void li_etag_set_header(liVRequest *vr, struct stat *st, gboolean *cachable) {
@ -144,12 +144,12 @@ void li_etag_set_header(liVRequest *vr, struct stat *st, gboolean *cachable) {
} }
if (flags & LI_ETAG_USE_SIZE) { if (flags & LI_ETAG_USE_SIZE) {
if (tmp_str->len != 0) li_g_string_append_len(tmp_str, CONST_STR_LEN("-")); if (tmp_str->len != 0) g_string_append_len(tmp_str, CONST_STR_LEN("-"));
li_string_append_int(tmp_str, st->st_size); li_string_append_int(tmp_str, st->st_size);
} }
if (flags & LI_ETAG_USE_MTIME) { if (flags & LI_ETAG_USE_MTIME) {
if (tmp_str->len != 0) li_g_string_append_len(tmp_str, CONST_STR_LEN("-")); if (tmp_str->len != 0) g_string_append_len(tmp_str, CONST_STR_LEN("-"));
li_string_append_int(tmp_str, st->st_mtime); li_string_append_int(tmp_str, st->st_mtime);
} }

View File

@ -72,9 +72,9 @@ static gboolean bod_open(bod_state *state) {
const char tmpl[] = "lighttpd-buffer-XXXXXX", basedir[] = "/var/tmp"; const char tmpl[] = "lighttpd-buffer-XXXXXX", basedir[] = "/var/tmp";
tmpfilename = g_string_sized_new((sizeof(basedir) - 1) + 1 + (sizeof(tmpl) - 1)); tmpfilename = g_string_sized_new((sizeof(basedir) - 1) + 1 + (sizeof(tmpl) - 1));
li_g_string_append_len(tmpfilename, CONST_STR_LEN(basedir)); /* TODO: add config option */ g_string_append_len(tmpfilename, CONST_STR_LEN(basedir)); /* TODO: add config option */
li_path_append_slash(tmpfilename); li_path_append_slash(tmpfilename);
li_g_string_append_len(tmpfilename, CONST_STR_LEN(tmpl)); g_string_append_len(tmpfilename, CONST_STR_LEN(tmpl));
fd = g_mkstemp(tmpfilename->str); fd = g_mkstemp(tmpfilename->str);
if (-1 == fd) { if (-1 == fd) {

View File

@ -209,8 +209,8 @@ void li_http_header_get_all(GString *dest, liHttpHeaders *headers, const gchar *
for (l = li_http_header_find_first(headers, key, keylen); l; l = li_http_header_find_next(l, key, keylen)) { for (l = li_http_header_find_first(headers, key, keylen); l; l = li_http_header_find_next(l, key, keylen)) {
liHttpHeader *h = (liHttpHeader*) l->data; liHttpHeader *h = (liHttpHeader*) l->data;
if (dest->len) li_g_string_append_len(dest, CONST_STR_LEN(", ")); if (dest->len) g_string_append_len(dest, CONST_STR_LEN(", "));
li_g_string_append_len(dest, &h->data->str[h->keylen+2], h->data->len - (h->keylen + 2)); g_string_append_len(dest, &h->data->str[h->keylen+2], h->data->len - (h->keylen + 2));
} }
} }

View File

@ -351,7 +351,7 @@ static void log_watcher_cb(liEventBase *watcher, int events) {
g_string_prepend_len(msg, GSTR_LEN(ts)); g_string_prepend_len(msg, GSTR_LEN(ts));
} }
li_g_string_append_len(msg, CONST_STR_LEN("\n")); g_string_append_len(msg, CONST_STR_LEN("\n"));
log = log_open(srv, log_entry->path); log = log_open(srv, log_entry->path);

View File

@ -1,100 +0,0 @@
src_shared = [
'angel.c',
'angel_fake.c',
'actions.c',
'base_lua.c',
'backends.c',
'chunk.c',
'chunk_parser.c',
'collect.c',
'condition.c',
'connection.c',
'environment.c',
'etag.c',
'filter.c',
'filter_chunked.c',
'filter_buffer_on_disk.c',
'http_headers.c',
'lighttpd_glue.c',
'log.c',
'mimetype.c',
'network.c',
'network_write.c',
'network_writev.c',
'network_sendfile.c',
'options.c',
'pattern.c',
'plugin.c',
'request.c',
'response.c',
'server.c',
'stat_cache.c',
'stream.c',
'stream_http_response.c',
'stream_simple_socket.c',
'throttle.c',
'value.c',
'virtualrequest.c',
'worker.c',
'plugin_core.c',
] + ragel_gen.process(
'http_range_parser.rl',
'http_request_parser.rl',
'http_response_parser.rl',
'url_parser.rl',
)
if not get_option('config-parser')
conf_data.set10('WITHOUT_CONFIG_PARSER', true)
else
src_shared += ragel_gen_t0.process('config_parser.rl')
endif
if get_option('lua')
src_shared += [
'actions_lua.c',
'condition_lua.c',
'config_lua.c',
'value_lua.c',
'chunk_lua.c',
'core_lua.c',
'environment_lua.c',
'filters_lua.c',
'http_headers_lua.c',
'physical_lua.c',
'request_lua.c',
'response_lua.c',
'stat_lua.c',
'subrequest_lua.c',
'virtualrequest_lua.c',
]
endif
lib_shared = library(
'lighttpd-' + meson.project_version() + '-shared',
src_shared,
include_directories: inc_dir,
dependencies: [
main_deps,
opt_dep_lua,
lib_m, # TODO: fmod in throttle.c
],
link_with: lib_common,
install: true,
)
bin_worker = executable(
'lighttpd2-worker',
'lighttpd_worker.c',
include_directories: inc_dir,
dependencies: [
main_deps,
opt_dep_lua,
],
link_with: [
lib_shared,
lib_common,
],
install: true,
install_dir: libexec_dir,
)

View File

@ -206,7 +206,7 @@ liPattern *li_pattern_new(liServer *srv, const gchar* str) {
/* copy every chunk between escapes into dest buffer */ /* copy every chunk between escapes into dest buffer */
for (first = c ; *c && '$' != *c && '%' != *c; c++) { for (first = c ; *c && '$' != *c && '%' != *c; c++) {
if (*c == '\\') { if (*c == '\\') {
if (first != c) li_g_string_append_len(part.data.str, first, c - first); if (first != c) g_string_append_len(part.data.str, first, c - first);
c++; c++;
first = c; first = c;
if (*c != '\\' && *c != '?' && *c != '$' && *c != '%') { if (*c != '\\' && *c != '?' && *c != '$' && *c != '%') {
@ -218,7 +218,7 @@ liPattern *li_pattern_new(liServer *srv, const gchar* str) {
} }
} }
} }
if (first != c) li_g_string_append_len(part.data.str, first, c - first); if (first != c) g_string_append_len(part.data.str, first, c - first);
g_array_append_val(pattern, part); g_array_append_val(pattern, part);
} }
@ -268,7 +268,7 @@ void li_pattern_eval(liVRequest *vr, GString *dest, liPattern *pattern, liPatter
switch (part->type) { switch (part->type) {
case PATTERN_STRING: case PATTERN_STRING:
li_g_string_append_len(dest, GSTR_LEN(part->data.str)); g_string_append_len(dest, GSTR_LEN(part->data.str));
break; break;
case PATTERN_NTH: case PATTERN_NTH:
if (NULL != nth_callback) { if (NULL != nth_callback) {
@ -315,7 +315,7 @@ void li_pattern_array_cb(GString *pattern_result, guint from, guint to, gpointer
for (i = from; i <= to; i++) { for (i = from; i <= to; i++) {
GString *str = g_array_index(a, GString*, i); GString *str = g_array_index(a, GString*, i);
if (NULL != str) { if (NULL != str) {
li_g_string_append_len(pattern_result, GSTR_LEN(str)); g_string_append_len(pattern_result, GSTR_LEN(str));
} }
} }
} else { } else {
@ -323,7 +323,7 @@ void li_pattern_array_cb(GString *pattern_result, guint from, guint to, gpointer
for (i = from + 1; i-- >= to; ) { for (i = from + 1; i-- >= to; ) {
GString *str = g_array_index(a, GString*, i); GString *str = g_array_index(a, GString*, i);
if (NULL != str) { if (NULL != str) {
li_g_string_append_len(pattern_result, GSTR_LEN(str)); g_string_append_len(pattern_result, GSTR_LEN(str));
} }
} }
} }
@ -340,14 +340,14 @@ void li_pattern_regex_cb(GString *pattern_result, guint from, guint to, gpointer
to = MIN(to, G_MAXINT); to = MIN(to, G_MAXINT);
for (i = from; i <= to; i++) { for (i = from; i <= to; i++) {
if (g_match_info_fetch_pos(match_info, (gint) i, &start_pos, &end_pos)) { if (g_match_info_fetch_pos(match_info, (gint) i, &start_pos, &end_pos)) {
li_g_string_append_len(pattern_result, g_match_info_get_string(match_info) + start_pos, end_pos - start_pos); g_string_append_len(pattern_result, g_match_info_get_string(match_info) + start_pos, end_pos - start_pos);
} }
} }
} else { } else {
from = MIN(from, G_MAXINT); /* => from+1 is defined */ from = MIN(from, G_MAXINT); /* => from+1 is defined */
for (i = from + 1; --i >= to; ) { for (i = from + 1; --i >= to; ) {
if (g_match_info_fetch_pos(match_info, (gint) i, &start_pos, &end_pos)) { if (g_match_info_fetch_pos(match_info, (gint) i, &start_pos, &end_pos)) {
li_g_string_append_len(pattern_result, g_match_info_get_string(match_info) + start_pos, end_pos - start_pos); g_string_append_len(pattern_result, g_match_info_get_string(match_info) + start_pos, end_pos - start_pos);
} }
} }
} }

View File

@ -16,7 +16,7 @@ static int lua_physical_attr_write_##attr(liPhysical *phys, lua_State *L) { \
luaL_checkstring(L, 3); \ luaL_checkstring(L, 3); \
s = lua_tolstring(L, 3, &len); \ s = lua_tolstring(L, 3, &len); \
g_string_truncate(phys->attr, 0); \ g_string_truncate(phys->attr, 0); \
li_g_string_append_len(phys->attr, s, len); \ g_string_append_len(phys->attr, s, len); \
return 0; \ return 0; \
} }

View File

@ -117,7 +117,7 @@ static void core_docroot_nth_cb(GString *pattern_result, guint to, guint from, g
/* ranges including 0 will only get the complete hostname */ /* ranges including 0 will only get the complete hostname */
if (0 == from || 0 == to) { if (0 == from || 0 == to) {
li_g_string_append_len(pattern_result, GSTR_LEN(ctx->hostname)); g_string_append_len(pattern_result, GSTR_LEN(ctx->hostname));
return; return;
} }
@ -136,7 +136,7 @@ static void core_docroot_nth_cb(GString *pattern_result, guint to, guint from, g
if (first) { if (first) {
first = FALSE; first = FALSE;
} else { } else {
li_g_string_append_len(pattern_result, CONST_STR_LEN(".")); g_string_append_len(pattern_result, CONST_STR_LEN("."));
} }
g_string_append(pattern_result, ctx->splits[ctx->split_len - i]); g_string_append(pattern_result, ctx->splits[ctx->split_len - i]);
} }
@ -145,7 +145,7 @@ static void core_docroot_nth_cb(GString *pattern_result, guint to, guint from, g
if (first) { if (first) {
first = FALSE; first = FALSE;
} else { } else {
li_g_string_append_len(pattern_result, CONST_STR_LEN(".")); g_string_append_len(pattern_result, CONST_STR_LEN("."));
} }
g_string_append(pattern_result, ctx->splits[ctx->split_len - i]); g_string_append(pattern_result, ctx->splits[ctx->split_len - i]);
} }
@ -210,10 +210,10 @@ static liHandlerResult core_handle_docroot(liVRequest *vr, gpointer param, gpoin
/* build physical path: docroot + uri.path */ /* build physical path: docroot + uri.path */
g_string_truncate(vr->physical.path, 0); g_string_truncate(vr->physical.path, 0);
li_g_string_append_len(vr->physical.path, GSTR_LEN(vr->physical.doc_root)); g_string_append_len(vr->physical.path, GSTR_LEN(vr->physical.doc_root));
if (vr->request.uri.path->len == 0 || vr->request.uri.path->str[0] != '/') if (vr->request.uri.path->len == 0 || vr->request.uri.path->str[0] != '/')
li_path_append_slash(vr->physical.path); li_path_append_slash(vr->physical.path);
li_g_string_append_len(vr->physical.path, GSTR_LEN(vr->request.uri.path)); g_string_append_len(vr->physical.path, GSTR_LEN(vr->request.uri.path));
if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) { if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {
VR_DEBUG(vr, "docroot: \"%s\"", vr->physical.doc_root->str); VR_DEBUG(vr, "docroot: \"%s\"", vr->physical.doc_root->str);
@ -316,8 +316,8 @@ static liHandlerResult core_handle_alias(liVRequest *vr, gpointer _param, gpoint
/* build physical path: docroot + uri.path */ /* build physical path: docroot + uri.path */
g_string_truncate(vr->physical.path, 0); g_string_truncate(vr->physical.path, 0);
li_g_string_append_len(vr->physical.path, GSTR_LEN(vr->physical.doc_root)); g_string_append_len(vr->physical.path, GSTR_LEN(vr->physical.doc_root));
li_g_string_append_len(vr->physical.path, vr->request.uri.path->str + preflen, vr->request.uri.path->len - preflen); g_string_append_len(vr->physical.path, vr->request.uri.path->str + preflen, vr->request.uri.path->len - preflen);
if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) { if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {
VR_DEBUG(vr, "alias physical path: %s", vr->physical.path->str); VR_DEBUG(vr, "alias physical path: %s", vr->physical.path->str);
@ -445,7 +445,7 @@ static liHandlerResult core_handle_index(liVRequest *vr, gpointer param, gpointe
/* we use two temporary strings here, one to append to docroot and one to append to physical path */ /* we use two temporary strings here, one to append to docroot and one to append to physical path */
tmp_docroot = vr->wrk->tmp_str; tmp_docroot = vr->wrk->tmp_str;
g_string_truncate(tmp_docroot, 0); g_string_truncate(tmp_docroot, 0);
li_g_string_append_len(vr->wrk->tmp_str, GSTR_LEN(vr->physical.doc_root)); g_string_append_len(vr->wrk->tmp_str, GSTR_LEN(vr->physical.doc_root));
tmp_path = g_string_new_len(GSTR_LEN(vr->physical.path)); tmp_path = g_string_new_len(GSTR_LEN(vr->physical.path));
/* loop through the list to find a possible index file */ /* loop through the list to find a possible index file */
@ -455,7 +455,7 @@ static liHandlerResult core_handle_index(liVRequest *vr, gpointer param, gpointe
if (file->str[0] == '/') { if (file->str[0] == '/') {
/* entries beginning with a slash shall be looked up directly at the docroot */ /* entries beginning with a slash shall be looked up directly at the docroot */
g_string_truncate(tmp_docroot, vr->physical.doc_root->len); g_string_truncate(tmp_docroot, vr->physical.doc_root->len);
li_g_string_append_len(tmp_docroot, GSTR_LEN(file)); g_string_append_len(tmp_docroot, GSTR_LEN(file));
if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) { if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {
VR_DEBUG(vr, "trying index file: '%s' -> '%s'", file->str, tmp_docroot->str); VR_DEBUG(vr, "trying index file: '%s' -> '%s'", file->str, tmp_docroot->str);
} }
@ -470,7 +470,7 @@ static liHandlerResult core_handle_index(liVRequest *vr, gpointer param, gpointe
} }
g_string_truncate(tmp_path, vr->physical.path->len); g_string_truncate(tmp_path, vr->physical.path->len);
li_g_string_append_len(tmp_path, GSTR_LEN(file)); g_string_append_len(tmp_path, GSTR_LEN(file));
if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) { if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {
VR_DEBUG(vr, "trying index file: '%s' -> '%s'", file->str, tmp_path->str); VR_DEBUG(vr, "trying index file: '%s' -> '%s'", file->str, tmp_path->str);
} }
@ -490,8 +490,8 @@ static liHandlerResult core_handle_index(liVRequest *vr, gpointer param, gpointe
g_string_truncate(vr->request.uri.path, 0); g_string_truncate(vr->request.uri.path, 0);
} }
li_g_string_append_len(vr->physical.path, GSTR_LEN(file)); g_string_append_len(vr->physical.path, GSTR_LEN(file));
li_g_string_append_len(vr->request.uri.path, GSTR_LEN(file)); g_string_append_len(vr->request.uri.path, GSTR_LEN(file));
if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) { if (CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {
VR_DEBUG(vr, "using index file: '%s'", file->str); VR_DEBUG(vr, "using index file: '%s'", file->str);
@ -1990,13 +1990,13 @@ static gboolean core_register_fetch_files_static(liServer *srv, liPlugin* p, liV
g_string_truncate(filename, 0); g_string_truncate(filename, 0);
if (NULL != basedir) { if (NULL != basedir) {
li_g_string_append_len(filename, GSTR_LEN(basedir)); g_string_append_len(filename, GSTR_LEN(basedir));
li_path_append_slash(filename); li_path_append_slash(filename);
} }
li_g_string_append_len(filename, GSTR_LEN(&entry)); g_string_append_len(filename, GSTR_LEN(&entry));
if (NULL != subfile) { if (NULL != subfile) {
li_path_append_slash(filename); li_path_append_slash(filename);
li_g_string_append_len(filename, GSTR_LEN(subfile)); g_string_append_len(filename, GSTR_LEN(subfile));
} }
if (!g_file_test(filename->str, G_FILE_TEST_IS_REGULAR)) continue; if (!g_file_test(filename->str, G_FILE_TEST_IS_REGULAR)) continue;

View File

@ -110,7 +110,7 @@ static gboolean request_parse_url(liVRequest *vr) {
li_path_simplify(req->uri.path); li_path_simplify(req->uri.path);
if (0 == req->uri.raw_orig_path->len) { if (0 == req->uri.raw_orig_path->len) {
li_g_string_append_len(req->uri.raw_orig_path, GSTR_LEN(req->uri.raw_path)); /* save orig raw uri */ g_string_append_len(req->uri.raw_orig_path, GSTR_LEN(req->uri.raw_path)); /* save orig raw uri */
} }
return TRUE; return TRUE;
@ -123,9 +123,9 @@ gboolean li_request_validate_header(liConnection *con) {
gboolean transfer_encoding_chunked = FALSE; gboolean transfer_encoding_chunked = FALSE;
if (con->info.is_ssl) { if (con->info.is_ssl) {
li_g_string_append_len(req->uri.scheme, CONST_STR_LEN("https")); g_string_append_len(req->uri.scheme, CONST_STR_LEN("https"));
} else { } else {
li_g_string_append_len(req->uri.scheme, CONST_STR_LEN("http")); g_string_append_len(req->uri.scheme, CONST_STR_LEN("http"));
} }
switch (req->http_version) { switch (req->http_version) {
@ -157,7 +157,7 @@ gboolean li_request_validate_header(liConnection *con) {
} }
hh = (liHttpHeader*) l->data; hh = (liHttpHeader*) l->data;
li_g_string_append_len(req->uri.authority, LI_HEADER_VALUE_LEN(hh)); g_string_append_len(req->uri.authority, LI_HEADER_VALUE_LEN(hh));
/* check header after we parsed the url, as it may override uri.authority */ /* check header after we parsed the url, as it may override uri.authority */
} }

View File

@ -163,7 +163,7 @@ static int lua_requesturi_attr_write_##attr(liRequestUri *uri, lua_State *L) { \
luaL_checkstring(L, 3); \ luaL_checkstring(L, 3); \
s = lua_tolstring(L, 3, &len); \ s = lua_tolstring(L, 3, &len); \
g_string_truncate(uri->attr, 0); \ g_string_truncate(uri->attr, 0); \
li_g_string_append_len(uri->attr, s, len); \ g_string_append_len(uri->attr, s, len); \
return 0; \ return 0; \
} }

View File

@ -80,9 +80,9 @@ void li_response_send_headers(liVRequest *vr, liChunkQueue *raw_out, liChunkQueu
/* Status line */ /* Status line */
if (vr->request.http_version == LI_HTTP_VERSION_1_1) { if (vr->request.http_version == LI_HTTP_VERSION_1_1) {
li_g_string_append_len(head, CONST_STR_LEN("HTTP/1.1 ")); g_string_append_len(head, CONST_STR_LEN("HTTP/1.1 "));
} else { } else {
li_g_string_append_len(head, CONST_STR_LEN("HTTP/1.0 ")); g_string_append_len(head, CONST_STR_LEN("HTTP/1.0 "));
} }
{ {
@ -91,20 +91,20 @@ void li_response_send_headers(liVRequest *vr, liChunkQueue *raw_out, liChunkQueu
gchar *str = li_http_status_string(vr->response.http_status, &len); gchar *str = li_http_status_string(vr->response.http_status, &len);
li_http_status_to_str(vr->response.http_status, status_str); li_http_status_to_str(vr->response.http_status, status_str);
status_str[3] = ' '; status_str[3] = ' ';
li_g_string_append_len(head, status_str, 4); g_string_append_len(head, status_str, 4);
li_g_string_append_len(head, str, len); g_string_append_len(head, str, len);
li_g_string_append_len(head, CONST_STR_LEN("\r\n")); g_string_append_len(head, CONST_STR_LEN("\r\n"));
} }
/* connection header, if needed. connection entries in the list are ignored below, send them directly */ /* connection header, if needed. connection entries in the list are ignored below, send them directly */
if (upgraded) { if (upgraded) {
li_g_string_append_len(head, CONST_STR_LEN("Connection: Upgrade\r\n")); g_string_append_len(head, CONST_STR_LEN("Connection: Upgrade\r\n"));
} else if (vr->request.http_version == LI_HTTP_VERSION_1_1) { } else if (vr->request.http_version == LI_HTTP_VERSION_1_1) {
if (!vr->coninfo->keep_alive) if (!vr->coninfo->keep_alive)
li_g_string_append_len(head, CONST_STR_LEN("Connection: close\r\n")); g_string_append_len(head, CONST_STR_LEN("Connection: close\r\n"));
} else { } else {
if (vr->coninfo->keep_alive) if (vr->coninfo->keep_alive)
li_g_string_append_len(head, CONST_STR_LEN("Connection: keep-alive\r\n")); g_string_append_len(head, CONST_STR_LEN("Connection: keep-alive\r\n"));
} }
/* Append headers */ /* Append headers */
@ -117,8 +117,8 @@ void li_response_send_headers(liVRequest *vr, liChunkQueue *raw_out, liChunkQueu
header = (liHttpHeader*) iter->data; header = (liHttpHeader*) iter->data;
/* ignore connection headers from backends. set con->info.keep_alive = FALSE to disable keep-alive */ /* ignore connection headers from backends. set con->info.keep_alive = FALSE to disable keep-alive */
if (li_http_header_key_is(header, CONST_STR_LEN("connection"))) continue; if (li_http_header_key_is(header, CONST_STR_LEN("connection"))) continue;
li_g_string_append_len(head, GSTR_LEN(header->data)); g_string_append_len(head, GSTR_LEN(header->data));
li_g_string_append_len(head, CONST_STR_LEN("\r\n")); g_string_append_len(head, CONST_STR_LEN("\r\n"));
if (!have_date && li_http_header_key_is(header, CONST_STR_LEN("date"))) have_date = TRUE; if (!have_date && li_http_header_key_is(header, CONST_STR_LEN("date"))) have_date = TRUE;
if (!have_server && li_http_header_key_is(header, CONST_STR_LEN("server"))) have_server = TRUE; if (!have_server && li_http_header_key_is(header, CONST_STR_LEN("server"))) have_server = TRUE;
} }
@ -126,23 +126,23 @@ void li_response_send_headers(liVRequest *vr, liChunkQueue *raw_out, liChunkQueu
if (!have_date) { if (!have_date) {
GString *d = li_worker_current_timestamp(vr->wrk, LI_GMTIME, LI_TS_FORMAT_HEADER); GString *d = li_worker_current_timestamp(vr->wrk, LI_GMTIME, LI_TS_FORMAT_HEADER);
/* HTTP/1.1 requires a Date: header */ /* HTTP/1.1 requires a Date: header */
li_g_string_append_len(head, CONST_STR_LEN("Date: ")); g_string_append_len(head, CONST_STR_LEN("Date: "));
li_g_string_append_len(head, GSTR_LEN(d)); g_string_append_len(head, GSTR_LEN(d));
li_g_string_append_len(head, CONST_STR_LEN("\r\n")); g_string_append_len(head, CONST_STR_LEN("\r\n"));
} }
if (!have_server) { if (!have_server) {
GString *tag = CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_TAG).string; GString *tag = CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_TAG).string;
if (tag->len) { if (tag->len) {
li_g_string_append_len(head, CONST_STR_LEN("Server: ")); g_string_append_len(head, CONST_STR_LEN("Server: "));
li_g_string_append_len(head, GSTR_LEN(tag)); g_string_append_len(head, GSTR_LEN(tag));
li_g_string_append_len(head, CONST_STR_LEN("\r\n")); g_string_append_len(head, CONST_STR_LEN("\r\n"));
} }
} }
} }
li_g_string_append_len(head, CONST_STR_LEN("\r\n")); g_string_append_len(head, CONST_STR_LEN("\r\n"));
li_chunkqueue_append_string(raw_out, head); li_chunkqueue_append_string(raw_out, head);
if (NULL != tmp_cq) { if (NULL != tmp_cq) {
@ -218,7 +218,7 @@ static void li_response_send_error_page(liVRequest *vr, liChunkQueue *response_b
html = g_string_sized_new(1023); html = g_string_sized_new(1023);
li_g_string_append_len(html, CONST_STR_LEN( g_string_append_len(html, CONST_STR_LEN(
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n" "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
"<html>\n" "<html>\n"
" <head>\n" " <head>\n"
@ -227,12 +227,12 @@ static void li_response_send_error_page(liVRequest *vr, liChunkQueue *response_b
li_http_status_to_str(vr->response.http_status, status_code); li_http_status_to_str(vr->response.http_status, status_code);
li_g_string_append_len(html, status_code, 3); g_string_append_len(html, status_code, 3);
li_g_string_append_len(html, CONST_STR_LEN(" - ")); g_string_append_len(html, CONST_STR_LEN(" - "));
str = li_http_status_string(vr->response.http_status, &len); str = li_http_status_string(vr->response.http_status, &len);
li_g_string_append_len(html, str, len); g_string_append_len(html, str, len);
li_g_string_append_len(html, CONST_STR_LEN( g_string_append_len(html, CONST_STR_LEN(
"</title>\n" "</title>\n"
" <style type=\"text/css\">\n" " <style type=\"text/css\">\n"
" body { font-size: 62.5%; }\n" " body { font-size: 62.5%; }\n"
@ -256,17 +256,17 @@ static void li_response_send_error_page(liVRequest *vr, liChunkQueue *response_b
" <h1>Error " " <h1>Error "
)); ));
li_g_string_append_len(html, status_code, 3); g_string_append_len(html, status_code, 3);
li_g_string_append_len(html, CONST_STR_LEN(" - ")); g_string_append_len(html, CONST_STR_LEN(" - "));
li_g_string_append_len(html, str, len); g_string_append_len(html, str, len);
li_g_string_append_len(html, CONST_STR_LEN("</h1>\n")); g_string_append_len(html, CONST_STR_LEN("</h1>\n"));
str = li_response_error_description(vr->response.http_status, &len); str = li_response_error_description(vr->response.http_status, &len);
li_g_string_append_len(html, str, len); g_string_append_len(html, str, len);
li_g_string_append_len(html, CONST_STR_LEN(" <p id=\"footer\">")); g_string_append_len(html, CONST_STR_LEN(" <p id=\"footer\">"));
li_g_string_append_len(html, GSTR_LEN(CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_TAG).string)); g_string_append_len(html, GSTR_LEN(CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_TAG).string));
li_g_string_append_len(html, CONST_STR_LEN( g_string_append_len(html, CONST_STR_LEN(
"</p>\n" "</p>\n"
" </div>\n" " </div>\n"
" </body>\n" " </body>\n"

View File

@ -120,7 +120,7 @@ static void stat_cache_run(gpointer data) {
sce->dirlist = g_array_sized_new(FALSE, FALSE, sizeof(liStatCacheEntryData), 32); sce->dirlist = g_array_sized_new(FALSE, FALSE, sizeof(liStatCacheEntryData), 32);
str = g_string_sized_new(sce->data.path->len + 64); str = g_string_sized_new(sce->data.path->len + 64);
li_g_string_append_len(str, GSTR_LEN(sce->data.path)); g_string_append_len(str, GSTR_LEN(sce->data.path));
/* glibc claims modern readdir are thread-safe, and /* glibc claims modern readdir are thread-safe, and
* readdir_r has issues. no way to check readdir is actually * readdir_r has issues. no way to check readdir is actually
@ -143,7 +143,7 @@ static void stat_cache_run(gpointer data) {
/* make sure the path ends with / (or whatever) */ /* make sure the path ends with / (or whatever) */
if (!sce->data.path->len || sce->data.path->str[sce->data.path->len-1] != G_DIR_SEPARATOR) if (!sce->data.path->len || sce->data.path->str[sce->data.path->len-1] != G_DIR_SEPARATOR)
g_string_append_c(str, G_DIR_SEPARATOR); g_string_append_c(str, G_DIR_SEPARATOR);
li_g_string_append_len(str, GSTR_LEN(sced.path)); g_string_append_len(str, GSTR_LEN(sced.path));
if (stat(str->str, &sced.st) == -1) { if (stat(str->str, &sced.st) == -1) {
sced.failed = TRUE; sced.failed = TRUE;

View File

@ -12,24 +12,24 @@
action save_host { action save_host {
g_string_truncate(uri->host, 0); g_string_truncate(uri->host, 0);
li_g_string_append_len(uri->host, host_mark, fpc - host_mark); g_string_append_len(uri->host, host_mark, fpc - host_mark);
g_string_ascii_down(uri->host); g_string_ascii_down(uri->host);
} }
action save_authority { action save_authority {
g_string_truncate(uri->authority, 0); g_string_truncate(uri->authority, 0);
li_g_string_append_len(uri->authority, mark, fpc - mark); g_string_append_len(uri->authority, mark, fpc - mark);
g_string_ascii_down(uri->authority); g_string_ascii_down(uri->authority);
} }
action save_path { action save_path {
li_g_string_append_len(uri->path, mark, fpc - mark); g_string_append_len(uri->path, mark, fpc - mark);
li_g_string_append_len(uri->raw_path, mark, fpc - mark); g_string_append_len(uri->raw_path, mark, fpc - mark);
} }
action save_query { action save_query {
li_g_string_append_len(uri->query, mark, fpc - mark); g_string_append_len(uri->query, mark, fpc - mark);
li_g_string_append_len(uri->raw_path, mark-1, fpc - mark+1); /* include '?' in append */ g_string_append_len(uri->raw_path, mark-1, fpc - mark+1); /* include '?' in append */
} }
action save_scheme { action save_scheme {
li_g_string_append_len(uri->scheme, mark, fpc - mark); g_string_append_len(uri->scheme, mark, fpc - mark);
} }
pct_encoded = "%" xdigit xdigit; pct_encoded = "%" xdigit xdigit;

View File

@ -557,18 +557,18 @@ gboolean li_vrequest_redirect_directory(liVRequest *vr) {
if (li_vrequest_is_handled(vr)) return FALSE; if (li_vrequest_is_handled(vr)) return FALSE;
g_string_truncate(uri, 0); g_string_truncate(uri, 0);
li_g_string_append_len(uri, GSTR_LEN(vr->request.uri.scheme)); g_string_append_len(uri, GSTR_LEN(vr->request.uri.scheme));
li_g_string_append_len(uri, CONST_STR_LEN("://")); g_string_append_len(uri, CONST_STR_LEN("://"));
if (vr->request.uri.authority->len > 0) { if (vr->request.uri.authority->len > 0) {
li_g_string_append_len(uri, GSTR_LEN(vr->request.uri.authority)); g_string_append_len(uri, GSTR_LEN(vr->request.uri.authority));
} else { } else {
li_g_string_append_len(uri, GSTR_LEN(vr->coninfo->local_addr_str)); g_string_append_len(uri, GSTR_LEN(vr->coninfo->local_addr_str));
} }
li_string_encode_append(vr->request.uri.path->str, uri, LI_ENCODING_URI); li_string_encode_append(vr->request.uri.path->str, uri, LI_ENCODING_URI);
g_string_append_c(uri, '/'); g_string_append_c(uri, '/');
if (vr->request.uri.query->len) { if (vr->request.uri.query->len) {
g_string_append_c(uri, '?'); g_string_append_c(uri, '?');
li_g_string_append_len(uri, GSTR_LEN(vr->request.uri.query)); g_string_append_len(uri, GSTR_LEN(vr->request.uri.query));
} }
return li_vrequest_redirect(vr, uri); return li_vrequest_redirect(vr, uri);

View File

@ -1,5 +0,0 @@
subdir('common')
subdir('angel')
subdir('main')
subdir('modules')
subdir('unittests')

View File

@ -1,113 +0,0 @@
modules = {
'access': {
'sources': ['mod_access.c'],
},
'accesslog': {
'sources': ['mod_accesslog.c'],
},
'auth': {
'sources': ['mod_auth.c'],
},
'balance': {
'sources': ['mod_balance.c'],
},
'cache_disk_etag': {
'sources': ['mod_cache_disk_etag.c'],
},
'debug': {
'sources': ['mod_debug.c'],
},
'deflate': {
'sources': ['mod_deflate.c'],
'dependencies': dep_deflate,
},
'dirlist': {
'sources': ['mod_dirlist.c'],
},
'expire': {
'sources': ['mod_expire.c'],
},
'fastcgi': {
'sources': ['mod_fastcgi.c', 'fastcgi_stream.c'],
},
'flv': {
'sources': ['mod_flv.c'],
},
'fortune': {
'sources': ['mod_fortune.c'],
},
'gnutls': {
'sources': ['mod_gnutls.c', 'gnutls_filter.c', 'gnutls_ocsp.c'],
'dependencies': [dep_gnutls, opt_dep_idn],
},
'limit': {
'sources': ['mod_limit.c'],
},
'lua': {
'sources': ['mod_lua.c'],
'dependencies': dep_lua,
},
'memcached': {
'sources': ['mod_memcached.c'],
'dependencies': opt_dep_lua,
},
'openssl': {
'sources': ['mod_openssl.c', 'openssl_filter.c'],
'dependencies': [dep_openssl, opt_dep_idn],
},
'progress': {
'sources': ['mod_progress.c'],
},
'proxy': {
'sources': ['mod_proxy.c'],
},
'redirect': {
'sources': ['mod_redirect.c'],
},
'rewrite': {
'sources': ['mod_rewrite.c'],
},
'scgi': {
'sources': ['mod_scgi.c'],
},
'status': {
'sources': ['mod_status.c'],
},
'throttle': {
'sources': ['mod_throttle.c'],
},
'userdir': {
'sources': ['mod_userdir.c'],
},
'vhost': {
'sources': ['mod_vhost.c'],
},
}
modules_build_dir = meson.current_build_dir()
all_modules = []
enabled_modules = []
foreach name, def: modules
deps = main_deps + def.get('dependencies', [])
expect_mod = true
foreach dep: deps
if not dep.found()
expect_mod = false
endif
endforeach
mod = shared_module(
'mod_' + name,
def['sources'],
dependencies: main_deps + def.get('dependencies', []),
c_args: def.get('c_args', []),
include_directories: inc_dir,
install: true,
install_dir: modules_dir,
)
all_modules += mod
if expect_mod
enabled_modules += mod
endif
endforeach

View File

@ -110,13 +110,13 @@ static void al_append_escaped(GString *log, GString *str) {
/* exceptions: " => \", \ => \\, whitespace chars => \n \t etc. */ /* exceptions: " => \", \ => \\, whitespace chars => \n \t etc. */
for (guint i = 0; i < str->len; i++) { for (guint i = 0; i < str->len; i++) {
switch (str->str[i]) { switch (str->str[i]) {
case '"': li_g_string_append_len(log, CONST_STR_LEN("\\\"")); break; case '"': g_string_append_len(log, CONST_STR_LEN("\\\"")); break;
case '\\': li_g_string_append_len(log, CONST_STR_LEN("\\\\")); break; case '\\': g_string_append_len(log, CONST_STR_LEN("\\\\")); break;
case '\b': li_g_string_append_len(log, CONST_STR_LEN("\\b")); break; case '\b': g_string_append_len(log, CONST_STR_LEN("\\b")); break;
case '\n': li_g_string_append_len(log, CONST_STR_LEN("\\n")); break; case '\n': g_string_append_len(log, CONST_STR_LEN("\\n")); break;
case '\r': li_g_string_append_len(log, CONST_STR_LEN("\\r")); break; case '\r': g_string_append_len(log, CONST_STR_LEN("\\r")); break;
case '\t': li_g_string_append_len(log, CONST_STR_LEN("\\t")); break; case '\t': g_string_append_len(log, CONST_STR_LEN("\\t")); break;
case '\v': li_g_string_append_len(log, CONST_STR_LEN("\\v")); break; case '\v': g_string_append_len(log, CONST_STR_LEN("\\v")); break;
default: default:
if (str->str[i] >= ' ' && str->str[i] <= '~') { if (str->str[i] >= ' ' && str->str[i] <= '~') {
/* printable chars */ /* printable chars */
@ -128,7 +128,7 @@ static void al_append_escaped(GString *log, GString *str) {
hh[2] = (h > 9) ? (h - 10 + 'A') : (h + '0'); hh[2] = (h > 9) ? (h - 10 + 'A') : (h + '0');
h = str->str[i] % 16; h = str->str[i] % 16;
hh[3] = (h > 9) ? (h - 10 + 'A') : (h + '0'); hh[3] = (h > 9) ? (h - 10 + 'A') : (h + '0');
li_g_string_append_len(log, &hh[0], 4); g_string_append_len(log, &hh[0], 4);
} }
break; break;
} }
@ -225,10 +225,10 @@ static GString *al_format_log(liVRequest *vr, al_data *ald, GArray *format) {
g_string_append_c(str, '%'); g_string_append_c(str, '%');
break; break;
case AL_FORMAT_REMOTE_ADDR: case AL_FORMAT_REMOTE_ADDR:
li_g_string_append_len(str, GSTR_LEN(vr->coninfo->remote_addr_str)); g_string_append_len(str, GSTR_LEN(vr->coninfo->remote_addr_str));
break; break;
case AL_FORMAT_LOCAL_ADDR: case AL_FORMAT_LOCAL_ADDR:
li_g_string_append_len(str, GSTR_LEN(vr->coninfo->local_addr_str)); g_string_append_len(str, GSTR_LEN(vr->coninfo->local_addr_str));
break; break;
case AL_FORMAT_BYTES_RESPONSE: case AL_FORMAT_BYTES_RESPONSE:
li_string_append_int(str, (NULL != vr->coninfo->resp) ? vr->coninfo->resp->out->bytes_out : 0); li_string_append_int(str, (NULL != vr->coninfo->resp) ? vr->coninfo->resp->out->bytes_out : 0);
@ -251,7 +251,7 @@ static GString *al_format_log(liVRequest *vr, al_data *ald, GArray *format) {
break; break;
case AL_FORMAT_FILENAME: case AL_FORMAT_FILENAME:
if (phys->path->len) if (phys->path->len)
li_g_string_append_len(str, GSTR_LEN(phys->path)); g_string_append_len(str, GSTR_LEN(phys->path));
else else
g_string_append_c(str, '-'); g_string_append_c(str, '-');
break; break;
@ -263,7 +263,7 @@ static GString *al_format_log(liVRequest *vr, al_data *ald, GArray *format) {
g_string_append_c(str, '-'); g_string_append_c(str, '-');
break; break;
case AL_FORMAT_METHOD: case AL_FORMAT_METHOD:
li_g_string_append_len(str, GSTR_LEN(req->http_method_str)); g_string_append_len(str, GSTR_LEN(req->http_method_str));
break; break;
case AL_FORMAT_RESPONSE_HEADER: case AL_FORMAT_RESPONSE_HEADER:
li_http_header_get_all(vr->wrk->tmp_str, resp->headers, GSTR_LEN(e->key)); li_http_header_get_all(vr->wrk->tmp_str, resp->headers, GSTR_LEN(e->key));
@ -288,12 +288,12 @@ static GString *al_format_log(liVRequest *vr, al_data *ald, GArray *format) {
g_string_append_c(str, '-'); g_string_append_c(str, '-');
break; break;
case AL_FORMAT_FIRST_LINE: case AL_FORMAT_FIRST_LINE:
li_g_string_append_len(str, GSTR_LEN(req->http_method_str)); g_string_append_len(str, GSTR_LEN(req->http_method_str));
g_string_append_c(str, ' '); g_string_append_c(str, ' ');
al_append_escaped(str, req->uri.raw_orig_path); al_append_escaped(str, req->uri.raw_orig_path);
g_string_append_c(str, ' '); g_string_append_c(str, ' ');
tmp_str = li_http_version_string(req->http_version, &len); tmp_str = li_http_version_string(req->http_version, &len);
li_g_string_append_len(str, tmp_str, len); g_string_append_len(str, tmp_str, len);
break; break;
case AL_FORMAT_STATUS_CODE: case AL_FORMAT_STATUS_CODE:
li_string_append_int(str, resp->http_status); li_string_append_int(str, resp->http_status);
@ -301,7 +301,7 @@ static GString *al_format_log(liVRequest *vr, al_data *ald, GArray *format) {
case AL_FORMAT_TIME: case AL_FORMAT_TIME:
/* todo: implement format string */ /* todo: implement format string */
tmp_gstr2 = li_worker_current_timestamp(vr->wrk, LI_LOCALTIME, ald->ts_ndx); tmp_gstr2 = li_worker_current_timestamp(vr->wrk, LI_LOCALTIME, ald->ts_ndx);
li_g_string_append_len(str, GSTR_LEN(tmp_gstr2)); g_string_append_len(str, GSTR_LEN(tmp_gstr2));
break; break;
case AL_FORMAT_DURATION_SECONDS: case AL_FORMAT_DURATION_SECONDS:
li_string_append_int(str, li_cur_ts(vr->wrk) - vr->ts_started); li_string_append_int(str, li_cur_ts(vr->wrk) - vr->ts_started);
@ -309,22 +309,22 @@ static GString *al_format_log(liVRequest *vr, al_data *ald, GArray *format) {
case AL_FORMAT_AUTHED_USER: case AL_FORMAT_AUTHED_USER:
tmp_gstr2 = li_environment_get(&vr->env, CONST_STR_LEN("REMOTE_USER")); tmp_gstr2 = li_environment_get(&vr->env, CONST_STR_LEN("REMOTE_USER"));
if (tmp_gstr2) if (tmp_gstr2)
li_g_string_append_len(str, GSTR_LEN(tmp_gstr2)); g_string_append_len(str, GSTR_LEN(tmp_gstr2));
else else
g_string_append_c(str, '-'); g_string_append_c(str, '-');
break; break;
case AL_FORMAT_PATH: case AL_FORMAT_PATH:
li_g_string_append_len(str, GSTR_LEN(req->uri.path)); g_string_append_len(str, GSTR_LEN(req->uri.path));
break; break;
case AL_FORMAT_SERVER_NAME: case AL_FORMAT_SERVER_NAME:
if (CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_NAME).string) if (CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_NAME).string)
li_g_string_append_len(str, GSTR_LEN(CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_NAME).string)); g_string_append_len(str, GSTR_LEN(CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_NAME).string));
else else
li_g_string_append_len(str, GSTR_LEN(req->uri.host)); g_string_append_len(str, GSTR_LEN(req->uri.host));
break; break;
case AL_FORMAT_HOSTNAME: case AL_FORMAT_HOSTNAME:
if (req->uri.host->len) if (req->uri.host->len)
li_g_string_append_len(str, GSTR_LEN(req->uri.host)); g_string_append_len(str, GSTR_LEN(req->uri.host));
else else
g_string_append_c(str, '-'); g_string_append_c(str, '-');
break; break;
@ -353,7 +353,7 @@ static GString *al_format_log(liVRequest *vr, al_data *ald, GArray *format) {
} }
} else { } else {
/* append normal string */ /* append normal string */
li_g_string_append_len(str, GSTR_LEN(e->key)); g_string_append_len(str, GSTR_LEN(e->key));
} }
} }

View File

@ -261,13 +261,7 @@ static gboolean auth_backend_htpasswd(liVRequest *vr, const GString *username, c
} }
} else { } else {
const GString salt = { (gchar*) pass, strlen(pass), 0 }; const GString salt = { (gchar*) pass, strlen(pass), 0 };
li_safe_crypt(vr->wrk->tmp_str, password, &salt);
if (!li_safe_crypt(vr->wrk->tmp_str, password, &salt)) {
if (debug) {
VR_DEBUG(vr, "Invalid password salt/hash \"%s\" for user \"%s\"", pass, username->str);
}
goto out;
}
if (0 != g_strcmp0(pass, vr->wrk->tmp_str->str)) { if (0 != g_strcmp0(pass, vr->wrk->tmp_str->str)) {
if (debug) { if (debug) {
@ -396,8 +390,8 @@ static liHandlerResult auth_basic(liVRequest *vr, gpointer param, gpointer *cont
} }
g_string_truncate(vr->wrk->tmp_str, 0); g_string_truncate(vr->wrk->tmp_str, 0);
li_g_string_append_len(vr->wrk->tmp_str, CONST_STR_LEN("Basic realm=\"")); g_string_append_len(vr->wrk->tmp_str, CONST_STR_LEN("Basic realm=\""));
li_g_string_append_len(vr->wrk->tmp_str, GSTR_LEN(bdata->realm)); g_string_append_len(vr->wrk->tmp_str, GSTR_LEN(bdata->realm));
g_string_append_c(vr->wrk->tmp_str, '"'); g_string_append_c(vr->wrk->tmp_str, '"');
/* generate header always */ /* generate header always */

View File

@ -65,8 +65,8 @@ static gboolean mkdir_for_file(liVRequest *vr, char *filename) {
static gboolean cache_etag_file_start(liVRequest *vr, cache_etag_file *cfile) { static gboolean cache_etag_file_start(liVRequest *vr, cache_etag_file *cfile) {
cfile->tmpfilename = g_string_sized_new(cfile->filename->len + 7); cfile->tmpfilename = g_string_sized_new(cfile->filename->len + 7);
li_g_string_append_len(cfile->tmpfilename, GSTR_LEN(cfile->filename)); g_string_append_len(cfile->tmpfilename, GSTR_LEN(cfile->filename));
li_g_string_append_len(cfile->tmpfilename, CONST_STR_LEN("-XXXXXX")); g_string_append_len(cfile->tmpfilename, CONST_STR_LEN("-XXXXXX"));
if (!mkdir_for_file(vr, cfile->tmpfilename->str)) { if (!mkdir_for_file(vr, cfile->tmpfilename->str)) {
return FALSE; return FALSE;
@ -207,9 +207,9 @@ forward:
static GString* createFileName(liVRequest *vr, GString *path, liHttpHeader *etagheader) { static GString* createFileName(liVRequest *vr, GString *path, liHttpHeader *etagheader) {
GString *file = g_string_sized_new(255); GString *file = g_string_sized_new(255);
gchar* etag_base64 = g_base64_encode((guchar*) LI_HEADER_VALUE_LEN(etagheader)); gchar* etag_base64 = g_base64_encode((guchar*) LI_HEADER_VALUE_LEN(etagheader));
li_g_string_append_len(file, GSTR_LEN(path)); g_string_append_len(file, GSTR_LEN(path));
li_g_string_append_len(file, GSTR_LEN(vr->request.uri.path)); g_string_append_len(file, GSTR_LEN(vr->request.uri.path));
li_g_string_append_len(file, CONST_STR_LEN("-")); g_string_append_len(file, CONST_STR_LEN("-"));
g_string_append(file, etag_base64); g_string_append(file, etag_base64);
g_free(etag_base64); g_free(etag_base64);
return file; return file;

View File

@ -161,7 +161,7 @@ static gpointer debug_collect_func(liWorker *wrk, gpointer fdata) {
cd->path->str, cd->path->str,
cd->query->str cd->query->str
); );
li_g_string_append_len(cd->detailed, CONST_STR_LEN("}</pre>")); g_string_append_len(cd->detailed, CONST_STR_LEN("}</pre>"));
} }
} }
} }
@ -211,7 +211,7 @@ static void debug_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result,
html = g_string_sized_new(2047); html = g_string_sized_new(2047);
li_g_string_append_len(html, CONST_STR_LEN("<html>\n<head>\n<title>Lighttpd mod_debug</title>\n" g_string_append_len(html, CONST_STR_LEN("<html>\n<head>\n<title>Lighttpd mod_debug</title>\n"
"<style>a { color: blue; }</style>\n" "<style>a { color: blue; }</style>\n"
"</head>\n<body>\n")); "</head>\n<body>\n"));
@ -225,7 +225,7 @@ static void debug_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result,
vr->wrk->io_timeout_queue.timer.libevmess.timer.repeat vr->wrk->io_timeout_queue.timer.libevmess.timer.repeat
); );
li_g_string_append_len(html, CONST_STR_LEN("<table><tr><th>Client</th><th>Duration</th><th></th></tr>\n")); g_string_append_len(html, CONST_STR_LEN("<table><tr><th>Client</th><th>Duration</th><th></th></tr>\n"));
for (i = 0; i < result->len; i++) { for (i = 0; i < result->len; i++) {
GArray *cons = g_ptr_array_index(result, i); GArray *cons = g_ptr_array_index(result, i);
@ -255,11 +255,11 @@ static void debug_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result,
g_array_free(cons, TRUE); g_array_free(cons, TRUE);
} }
li_g_string_append_len(html, CONST_STR_LEN("</table>\n")); g_string_append_len(html, CONST_STR_LEN("</table>\n"));
g_string_free(duration, TRUE); g_string_free(duration, TRUE);
} }
li_g_string_append_len(html, CONST_STR_LEN("</body>\n</html>\n")); g_string_append_len(html, CONST_STR_LEN("</body>\n</html>\n"));
if (li_vrequest_handle_direct(vr)) { if (li_vrequest_handle_direct(vr)) {
li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html; charset=utf-8")); li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html; charset=utf-8"));

View File

@ -485,12 +485,12 @@ static gboolean cached_handle_etag(liVRequest *vr, gboolean debug, liHttpHeader
if (!hh_etag) return FALSE; if (!hh_etag) return FALSE;
g_string_truncate(s, 0); g_string_truncate(s, 0);
li_g_string_append_len(s, LI_HEADER_VALUE_LEN(hh_etag)); g_string_append_len(s, LI_HEADER_VALUE_LEN(hh_etag));
li_g_string_append_len(s, CONST_STR_LEN("-")); g_string_append_len(s, CONST_STR_LEN("-"));
li_g_string_append_len(s, enc_name, strlen(enc_name)); g_string_append_len(s, enc_name, strlen(enc_name));
li_etag_mutate(s, s); li_etag_mutate(s, s);
g_string_truncate(hh_etag->data, hh_etag->keylen + 2); g_string_truncate(hh_etag->data, hh_etag->keylen + 2);
li_g_string_append_len(hh_etag->data, GSTR_LEN(s)); g_string_append_len(hh_etag->data, GSTR_LEN(s));
if (200 == vr->response.http_status && li_http_response_handle_cachable(vr)) { if (200 == vr->response.http_status && li_http_response_handle_cachable(vr)) {
if (debug || CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) { if (debug || CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {

View File

@ -206,7 +206,7 @@ typedef struct dirlist_plugin_data dirlist_plugin_data;
static void try_append_file(liVRequest *vr, GString **curbuf, const gchar *filename, gboolean encode_html) { static void try_append_file(liVRequest *vr, GString **curbuf, const gchar *filename, gboolean encode_html) {
GString *f = vr->wrk->tmp_str; GString *f = vr->wrk->tmp_str;
g_string_truncate(f, 0); g_string_truncate(f, 0);
li_g_string_append_len(f, GSTR_LEN(vr->physical.path)); g_string_append_len(f, GSTR_LEN(vr->physical.path));
li_path_append_slash(f); li_path_append_slash(f);
g_string_append(f, filename); g_string_append(f, filename);
@ -246,9 +246,9 @@ static void try_append_file(liVRequest *vr, GString **curbuf, const gchar *filen
return; /* file too big, ignore */ return; /* file too big, ignore */
} }
li_g_string_append_len(*curbuf, CONST_STR_LEN("<pre>")); g_string_append_len(*curbuf, CONST_STR_LEN("<pre>"));
li_string_encode_append(contents, *curbuf, LI_ENCODING_HTML); li_string_encode_append(contents, *curbuf, LI_ENCODING_HTML);
li_g_string_append_len(*curbuf, CONST_STR_LEN("</pre>")); g_string_append_len(*curbuf, CONST_STR_LEN("</pre>"));
g_free(contents); g_free(contents);
} }
} }
@ -435,14 +435,14 @@ static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context
if (dd->css) { if (dd->css) {
/* custom css */ /* custom css */
li_g_string_append_len(listing, CONST_STR_LEN(" <link rel=\"stylesheet\" type=\"text/css\" href=\"")); g_string_append_len(listing, CONST_STR_LEN(" <link rel=\"stylesheet\" type=\"text/css\" href=\""));
li_g_string_append_len(listing, GSTR_LEN(dd->css)); g_string_append_len(listing, GSTR_LEN(dd->css));
li_g_string_append_len(listing, CONST_STR_LEN("\" />\n")); g_string_append_len(listing, CONST_STR_LEN("\" />\n"));
} else { } else {
/* default css */ /* default css */
li_g_string_append_len(listing, CONST_STR_LEN(html_css)); g_string_append_len(listing, CONST_STR_LEN(html_css));
} }
li_g_string_append_len(listing, CONST_STR_LEN(html_header_end)); g_string_append_len(listing, CONST_STR_LEN(html_header_end));
try_append_file(vr, &listing, "HEADER.txt", dd->encode_header); try_append_file(vr, &listing, "HEADER.txt", dd->encode_header);
@ -462,23 +462,23 @@ static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context
datebuflen = strftime(datebuf, sizeof(datebuf), "%Y-%b-%d %H:%M:%S", &tm); datebuflen = strftime(datebuf, sizeof(datebuf), "%Y-%b-%d %H:%M:%S", &tm);
datebuf[datebuflen] = '\0'; datebuf[datebuflen] = '\0';
li_g_string_append_len(listing, CONST_STR_LEN(" <tr group=\"1\"><td><a href=\"")); g_string_append_len(listing, CONST_STR_LEN(" <tr group=\"1\"><td><a href=\""));
li_string_encode(sced->path->str, encoded, LI_ENCODING_URI); li_string_encode(sced->path->str, encoded, LI_ENCODING_URI);
li_g_string_append_len(listing, GSTR_LEN(encoded)); g_string_append_len(listing, GSTR_LEN(encoded));
li_g_string_append_len(listing, CONST_STR_LEN("/\">")); g_string_append_len(listing, CONST_STR_LEN("/\">"));
li_string_encode(sced->path->str, encoded, LI_ENCODING_HTML); li_string_encode(sced->path->str, encoded, LI_ENCODING_HTML);
li_g_string_append_len(listing, GSTR_LEN(encoded)); g_string_append_len(listing, GSTR_LEN(encoded));
li_g_string_append_len(listing, CONST_STR_LEN("</a></td><td class=\"modified\" val=\"")); g_string_append_len(listing, CONST_STR_LEN("</a></td><td class=\"modified\" val=\""));
li_string_append_int(listing, sced->st.st_mtime); li_string_append_int(listing, sced->st.st_mtime);
li_g_string_append_len(listing, CONST_STR_LEN("\">")); g_string_append_len(listing, CONST_STR_LEN("\">"));
li_g_string_append_len(listing, datebuf, datebuflen); g_string_append_len(listing, datebuf, datebuflen);
li_g_string_append_len(listing, CONST_STR_LEN("</td>" g_string_append_len(listing, CONST_STR_LEN("</td>"
"<td class=\"size\" val=\"0\">-</td>" "<td class=\"size\" val=\"0\">-</td>"
"<td class=\"type\">Directory</td></tr>\n")); "<td class=\"type\">Directory</td></tr>\n"));
} }
} }
/*li_g_string_append_len(listing, CONST_STR_LEN("<tr><td colspan=\"4\">&nbsp;</td></tr>\n"));*/ /*g_string_append_len(listing, CONST_STR_LEN("<tr><td colspan=\"4\">&nbsp;</td></tr>\n"));*/
/* list files */ /* list files */
for (i = 0; i < files->len; i++) { for (i = 0; i < files->len; i++) {
@ -491,29 +491,29 @@ static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context
dirlist_format_size(sizebuf, sced->st.st_size); dirlist_format_size(sizebuf, sced->st.st_size);
li_g_string_append_len(listing, CONST_STR_LEN(" <tr group=\"2\"><td><a href=\"")); g_string_append_len(listing, CONST_STR_LEN(" <tr group=\"2\"><td><a href=\""));
li_string_encode(sced->path->str, encoded, LI_ENCODING_URI); li_string_encode(sced->path->str, encoded, LI_ENCODING_URI);
li_g_string_append_len(listing, GSTR_LEN(encoded)); g_string_append_len(listing, GSTR_LEN(encoded));
li_g_string_append_len(listing, CONST_STR_LEN("\">")); g_string_append_len(listing, CONST_STR_LEN("\">"));
li_string_encode(sced->path->str, encoded, LI_ENCODING_HTML); li_string_encode(sced->path->str, encoded, LI_ENCODING_HTML);
li_g_string_append_len(listing, GSTR_LEN(encoded)); g_string_append_len(listing, GSTR_LEN(encoded));
li_g_string_append_len(listing, CONST_STR_LEN( g_string_append_len(listing, CONST_STR_LEN(
"</a></td>" "</a></td>"
"<td class=\"modified\" val=\"")); "<td class=\"modified\" val=\""));
li_string_append_int(listing, sced->st.st_mtime); li_string_append_int(listing, sced->st.st_mtime);
li_g_string_append_len(listing, CONST_STR_LEN("\">")); g_string_append_len(listing, CONST_STR_LEN("\">"));
li_g_string_append_len(listing, datebuf, datebuflen); g_string_append_len(listing, datebuf, datebuflen);
li_g_string_append_len(listing, CONST_STR_LEN("</td><td class=\"size\" val=\"")); g_string_append_len(listing, CONST_STR_LEN("</td><td class=\"size\" val=\""));
li_string_append_int(listing, sced->st.st_size); li_string_append_int(listing, sced->st.st_size);
li_g_string_append_len(listing, CONST_STR_LEN("\">")); g_string_append_len(listing, CONST_STR_LEN("\">"));
g_string_append(listing, sizebuf); g_string_append(listing, sizebuf);
li_g_string_append_len(listing, CONST_STR_LEN("</td><td class=\"type\">")); g_string_append_len(listing, CONST_STR_LEN("</td><td class=\"type\">"));
if (mime_str) { if (mime_str) {
li_g_string_append_len(listing, GSTR_LEN(mime_str)); g_string_append_len(listing, GSTR_LEN(mime_str));
} else { } else {
li_g_string_append_len(listing, CONST_STR_LEN("application/octet-stream")); g_string_append_len(listing, CONST_STR_LEN("application/octet-stream"));
} }
li_g_string_append_len(listing, CONST_STR_LEN("</td></tr>\n")); g_string_append_len(listing, CONST_STR_LEN("</td></tr>\n"));
/* /*
g_string_append_printf(listing, html_table_row, g_string_append_printf(listing, html_table_row,
@ -524,12 +524,12 @@ static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context
*/ */
} }
li_g_string_append_len(listing, CONST_STR_LEN(html_table_end)); g_string_append_len(listing, CONST_STR_LEN(html_table_end));
try_append_file(vr, &listing, "README.txt", dd->encode_readme); try_append_file(vr, &listing, "README.txt", dd->encode_readme);
if (dd->include_sort) { if (dd->include_sort) {
li_g_string_append_len(listing, CONST_STR_LEN(javascript_sort)); g_string_append_len(listing, CONST_STR_LEN(javascript_sort));
} }
g_string_append_printf(listing, html_footer, CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_TAG).string->str); g_string_append_printf(listing, html_footer, CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_TAG).string->str);

View File

@ -80,7 +80,7 @@ static liHandlerResult expire(liVRequest *vr, gpointer param, gpointer *context)
/* finally set the headers */ /* finally set the headers */
li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Expires"), GSTR_LEN(date_str)); li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Expires"), GSTR_LEN(date_str));
g_string_truncate(date_str, 0); g_string_truncate(date_str, 0);
li_g_string_append_len(date_str, CONST_STR_LEN("max-age=")); g_string_append_len(date_str, CONST_STR_LEN("max-age="));
li_string_append_int(date_str, max_age); li_string_append_int(date_str, max_age);
li_http_header_append(vr->response.headers, CONST_STR_LEN("Cache-Control"), GSTR_LEN(date_str)); li_http_header_append(vr->response.headers, CONST_STR_LEN("Cache-Control"), GSTR_LEN(date_str));

View File

@ -1016,7 +1016,7 @@ static gboolean gnutls_setup(liServer *srv, liPlugin* p, liValue *val, gpointer
if (protect_against_beast) { if (protect_against_beast) {
g_string_assign(s, priority); g_string_assign(s, priority);
li_g_string_append_len(s, CONST_STR_LEN(":-CIPHER-ALL:+ARCFOUR-128")); g_string_append_len(s, CONST_STR_LEN(":-CIPHER-ALL:+ARCFOUR-128"));
if (GNUTLS_E_SUCCESS > (r = gnutls_priority_init(&prio, s->str, &errpos))) { if (GNUTLS_E_SUCCESS > (r = gnutls_priority_init(&prio, s->str, &errpos))) {
ERROR(srv, "gnutls_priority_init failed(priority '%s', error at '%s') (%s): %s", ERROR(srv, "gnutls_priority_init failed(priority '%s', error at '%s') (%s): %s",
s->str, errpos, s->str, errpos,

View File

@ -63,7 +63,7 @@ static gboolean lua_find_file(GString *filename) {
/* try DEFAULT_LUADIR */ /* try DEFAULT_LUADIR */
li_string_assign_len(tmp, CONST_STR_LEN(DEFAULT_LUADIR "/")); li_string_assign_len(tmp, CONST_STR_LEN(DEFAULT_LUADIR "/"));
li_g_string_append_len(tmp, GSTR_LEN(filename)); g_string_append_len(tmp, GSTR_LEN(filename));
if (-1 != stat(tmp->str, &st) && S_ISREG(st.st_mode)) { if (-1 != stat(tmp->str, &st) && S_ISREG(st.st_mode)) {
li_string_assign_len(filename, GSTR_LEN(tmp)); li_string_assign_len(filename, GSTR_LEN(tmp));
} else { } else {

View File

@ -245,7 +245,7 @@ static void openssl_setenv_X509_add_entries(liVRequest *vr, X509 *x509, const gc
const char * xobjsn; const char * xobjsn;
g_string_truncate(k, 0); g_string_truncate(k, 0);
li_g_string_append_len(k, prefix, prefix_len); g_string_append_len(k, prefix, prefix_len);
for (i = 0, j = X509_NAME_entry_count(xn); i < j; ++i) { for (i = 0, j = X509_NAME_entry_count(xn); i < j; ++i) {
if (!(xe = X509_NAME_get_entry(xn, i)) if (!(xe = X509_NAME_get_entry(xn, i))

View File

@ -219,7 +219,7 @@ static void progress_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *resu
li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("application/x-javascript")); li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("application/x-javascript"));
if (format == PROGRESS_FORMAT_LEGACY) { if (format == PROGRESS_FORMAT_LEGACY) {
li_g_string_append_len(output, CONST_STR_LEN("new Object(")); g_string_append_len(output, CONST_STR_LEN("new Object("));
} else if (format == PROGRESS_FORMAT_JSONP) { } else if (format == PROGRESS_FORMAT_JSONP) {
gchar *val; gchar *val;
guint len; guint len;
@ -236,13 +236,13 @@ static void progress_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *resu
/* was there a bad char? */ /* was there a bad char? */
if (c != val+len) { if (c != val+len) {
li_g_string_append_len(output, CONST_STR_LEN("progress(")); g_string_append_len(output, CONST_STR_LEN("progress("));
} else { } else {
li_g_string_append_len(output,val, len); g_string_append_len(output,val, len);
g_string_append_c(output, '('); g_string_append_c(output, '(');
} }
} else { } else {
li_g_string_append_len(output, CONST_STR_LEN("progress(")); g_string_append_len(output, CONST_STR_LEN("progress("));
} }
} }
@ -251,7 +251,7 @@ static void progress_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *resu
if (debug) if (debug)
VR_DEBUG(vr, "progress.show: progress id \"%s\" unknown", job->id); VR_DEBUG(vr, "progress.show: progress id \"%s\" unknown", job->id);
li_g_string_append_len(output, CONST_STR_LEN("{\"state\": \"unknown\"}")); g_string_append_len(output, CONST_STR_LEN("{\"state\": \"unknown\"}"));
} else { } else {
if (debug) if (debug)
VR_DEBUG(vr, "progress.show: progress id \"%s\" found", job->id); VR_DEBUG(vr, "progress.show: progress id \"%s\" found", job->id);

View File

@ -45,27 +45,27 @@ static void proxy_send_headers(liVRequest *vr, liChunkQueue *out) {
liHttpHeaderTokenizer header_tokenizer; liHttpHeaderTokenizer header_tokenizer;
GString *tmp_str = vr->wrk->tmp_str; GString *tmp_str = vr->wrk->tmp_str;
li_g_string_append_len(head, GSTR_LEN(vr->request.http_method_str)); g_string_append_len(head, GSTR_LEN(vr->request.http_method_str));
li_g_string_append_len(head, CONST_STR_LEN(" ")); g_string_append_len(head, CONST_STR_LEN(" "));
li_g_string_append_len(head, GSTR_LEN(vr->request.uri.raw_path)); g_string_append_len(head, GSTR_LEN(vr->request.uri.raw_path));
switch (vr->request.http_version) { switch (vr->request.http_version) {
case LI_HTTP_VERSION_1_1: case LI_HTTP_VERSION_1_1:
li_g_string_append_len(head, CONST_STR_LEN(" HTTP/1.1\r\n")); g_string_append_len(head, CONST_STR_LEN(" HTTP/1.1\r\n"));
/* although we understand keep-alive signalling we don't reuse connection, so tell backend */ /* although we understand keep-alive signalling we don't reuse connection, so tell backend */
li_g_string_append_len(head, CONST_STR_LEN("Connection: close\r\n")); g_string_append_len(head, CONST_STR_LEN("Connection: close\r\n"));
break; break;
case LI_HTTP_VERSION_1_0: case LI_HTTP_VERSION_1_0:
default: default:
li_g_string_append_len(head, CONST_STR_LEN(" HTTP/1.0\r\n")); g_string_append_len(head, CONST_STR_LEN(" HTTP/1.0\r\n"));
break; break;
} }
li_http_header_tokenizer_start(&header_tokenizer, vr->request.headers, CONST_STR_LEN("Connection")); li_http_header_tokenizer_start(&header_tokenizer, vr->request.headers, CONST_STR_LEN("Connection"));
while (li_http_header_tokenizer_next(&header_tokenizer, tmp_str)) { while (li_http_header_tokenizer_next(&header_tokenizer, tmp_str)) {
if (0 == g_ascii_strcasecmp(tmp_str->str, "Upgrade")) { if (0 == g_ascii_strcasecmp(tmp_str->str, "Upgrade")) {
li_g_string_append_len(head, CONST_STR_LEN("Connection: Upgrade\r\n")); g_string_append_len(head, CONST_STR_LEN("Connection: Upgrade\r\n"));
} }
} }
@ -82,22 +82,22 @@ static void proxy_send_headers(liVRequest *vr, liChunkQueue *out) {
if (li_http_header_key_is(header, CONST_STR_LEN("Proxy-Connection"))) continue; if (li_http_header_key_is(header, CONST_STR_LEN("Proxy-Connection"))) continue;
if (li_http_header_key_is(header, CONST_STR_LEN("X-Forwarded-Proto"))) continue; if (li_http_header_key_is(header, CONST_STR_LEN("X-Forwarded-Proto"))) continue;
if (li_http_header_key_is(header, CONST_STR_LEN("X-Forwarded-For"))) continue; if (li_http_header_key_is(header, CONST_STR_LEN("X-Forwarded-For"))) continue;
li_g_string_append_len(head, GSTR_LEN(header->data)); g_string_append_len(head, GSTR_LEN(header->data));
li_g_string_append_len(head, CONST_STR_LEN("\r\n")); g_string_append_len(head, CONST_STR_LEN("\r\n"));
} }
li_g_string_append_len(head, CONST_STR_LEN("X-Forwarded-For: ")); g_string_append_len(head, CONST_STR_LEN("X-Forwarded-For: "));
li_g_string_append_len(head, GSTR_LEN(vr->coninfo->remote_addr_str)); g_string_append_len(head, GSTR_LEN(vr->coninfo->remote_addr_str));
li_g_string_append_len(head, CONST_STR_LEN("\r\n")); g_string_append_len(head, CONST_STR_LEN("\r\n"));
if (vr->coninfo->is_ssl) { if (vr->coninfo->is_ssl) {
li_g_string_append_len(head, CONST_STR_LEN("X-Forwarded-Proto: https\r\n")); g_string_append_len(head, CONST_STR_LEN("X-Forwarded-Proto: https\r\n"));
} else { } else {
li_g_string_append_len(head, CONST_STR_LEN("X-Forwarded-Proto: http\r\n")); g_string_append_len(head, CONST_STR_LEN("X-Forwarded-Proto: http\r\n"));
} }
/* terminate http header */ /* terminate http header */
li_g_string_append_len(head, CONST_STR_LEN("\r\n")); g_string_append_len(head, CONST_STR_LEN("\r\n"));
li_chunkqueue_append_string(out, head); li_chunkqueue_append_string(out, head);
} }

View File

@ -111,15 +111,15 @@ static gboolean redirect_internal(liVRequest *vr, GString *dest, redirect_rule *
break; break;
case REDIRECT_ABSOLUTE_PATH: case REDIRECT_ABSOLUTE_PATH:
/* /foo/bar?baz */ /* /foo/bar?baz */
li_g_string_append_len(dest, GSTR_LEN(vr->request.uri.scheme)); g_string_append_len(dest, GSTR_LEN(vr->request.uri.scheme));
li_g_string_append_len(dest, CONST_STR_LEN("://")); g_string_append_len(dest, CONST_STR_LEN("://"));
li_g_string_append_len(dest, GSTR_LEN(vr->request.uri.authority)); g_string_append_len(dest, GSTR_LEN(vr->request.uri.authority));
break; break;
case REDIRECT_RELATIVE_PATH: case REDIRECT_RELATIVE_PATH:
/* foo/bar?baz */ /* foo/bar?baz */
li_g_string_append_len(dest, GSTR_LEN(vr->request.uri.scheme)); g_string_append_len(dest, GSTR_LEN(vr->request.uri.scheme));
li_g_string_append_len(dest, CONST_STR_LEN("://")); g_string_append_len(dest, CONST_STR_LEN("://"));
li_g_string_append_len(dest, GSTR_LEN(vr->request.uri.authority)); g_string_append_len(dest, GSTR_LEN(vr->request.uri.authority));
/* search for last slash /foo/bar */ /* search for last slash /foo/bar */
{ {
gchar *c; gchar *c;
@ -127,15 +127,15 @@ static gboolean redirect_internal(liVRequest *vr, GString *dest, redirect_rule *
if (*c == '/') break; if (*c == '/') break;
} }
li_g_string_append_len(dest, vr->request.uri.path->str, c - vr->request.uri.path->str + 1); g_string_append_len(dest, vr->request.uri.path->str, c - vr->request.uri.path->str + 1);
} }
break; break;
case REDIRECT_RELATIVE_QUERY: case REDIRECT_RELATIVE_QUERY:
/* ?bar */ /* ?bar */
li_g_string_append_len(dest, GSTR_LEN(vr->request.uri.scheme)); g_string_append_len(dest, GSTR_LEN(vr->request.uri.scheme));
li_g_string_append_len(dest, CONST_STR_LEN("://")); g_string_append_len(dest, CONST_STR_LEN("://"));
li_g_string_append_len(dest, GSTR_LEN(vr->request.uri.authority)); g_string_append_len(dest, GSTR_LEN(vr->request.uri.authority));
li_g_string_append_len(dest, GSTR_LEN(vr->request.uri.path)); g_string_append_len(dest, GSTR_LEN(vr->request.uri.path));
break; break;
} }

View File

@ -190,19 +190,19 @@ static liHandlerResult rewrite(liVRequest *vr, gpointer param, gpointer *context
/* change request query */ /* change request query */
if (NULL != rule->querystring) { if (NULL != rule->querystring) {
g_string_truncate(vr->request.uri.query, 0); g_string_truncate(vr->request.uri.query, 0);
li_g_string_append_len(vr->request.uri.query, GSTR_LEN(dest_query)); g_string_append_len(vr->request.uri.query, GSTR_LEN(dest_query));
} }
/* change request path */ /* change request path */
g_string_truncate(vr->request.uri.path, 0); g_string_truncate(vr->request.uri.path, 0);
li_g_string_append_len(vr->request.uri.path, GSTR_LEN(dest_path)); g_string_append_len(vr->request.uri.path, GSTR_LEN(dest_path));
li_path_simplify(vr->request.uri.path); li_path_simplify(vr->request.uri.path);
/* rebuild raw_path */ /* rebuild raw_path */
li_string_encode(vr->request.uri.path->str, vr->request.uri.raw_path, LI_ENCODING_URI); li_string_encode(vr->request.uri.path->str, vr->request.uri.raw_path, LI_ENCODING_URI);
if (vr->request.uri.query->len > 0) { if (vr->request.uri.query->len > 0) {
li_g_string_append_len(vr->request.uri.raw_path, CONST_STR_LEN("?")); g_string_append_len(vr->request.uri.raw_path, CONST_STR_LEN("?"));
li_g_string_append_len(vr->request.uri.raw_path, GSTR_LEN(vr->request.uri.query)); g_string_append_len(vr->request.uri.raw_path, GSTR_LEN(vr->request.uri.query));
} }
/* stop at first matching regex */ /* stop at first matching regex */

View File

@ -547,30 +547,30 @@ static GString *status_info_full(liVRequest *vr, liPlugin *p, gboolean short_inf
count_mem = g_string_sized_new(10); count_mem = g_string_sized_new(10);
tmpstr = vr->wrk->tmp_str; tmpstr = vr->wrk->tmp_str;
li_g_string_append_len(html, CONST_STR_LEN(html_header)); g_string_append_len(html, CONST_STR_LEN(html_header));
li_g_string_append_len(html, CONST_STR_LEN(html_js)); g_string_append_len(html, CONST_STR_LEN(html_js));
/* auto refresh */ /* auto refresh */
if (li_querystring_find(vr->request.uri.query, CONST_STR_LEN("refresh"), &val, &len)) { if (li_querystring_find(vr->request.uri.query, CONST_STR_LEN("refresh"), &val, &len)) {
li_g_string_append_len(html, CONST_STR_LEN("<meta http-equiv=\"refresh\" content=\"")); g_string_append_len(html, CONST_STR_LEN("<meta http-equiv=\"refresh\" content=\""));
/* temp char swap */ /* temp char swap */
c = val[len]; val[len] = '\0'; c = val[len]; val[len] = '\0';
li_string_encode_append(val, html, LI_ENCODING_HTML); li_string_encode_append(val, html, LI_ENCODING_HTML);
val[len] = c; val[len] = c;
li_g_string_append_len(html, CONST_STR_LEN("\">\n")); g_string_append_len(html, CONST_STR_LEN("\">\n"));
} }
/* css */ /* css */
css = _OPTIONPTR(vr, p, 0).string; css = _OPTIONPTR(vr, p, 0).string;
if (!css || !css->len) /* default css */ if (!css || !css->len) /* default css */
li_g_string_append_len(html, CONST_STR_LEN(css_default)); g_string_append_len(html, CONST_STR_LEN(css_default));
else if (g_str_equal(css->str, "blue")) /* blue css */ else if (g_str_equal(css->str, "blue")) /* blue css */
li_g_string_append_len(html, CONST_STR_LEN(css_blue)); g_string_append_len(html, CONST_STR_LEN(css_blue));
else /* external css */ else /* external css */
g_string_append_printf(html, " <link rel=\"stylesheet\" rev=\"stylesheet\" href=\"%s\" media=\"screen\" />\n", css->str); g_string_append_printf(html, " <link rel=\"stylesheet\" rev=\"stylesheet\" href=\"%s\" media=\"screen\" />\n", css->str);
li_g_string_append_len(html, CONST_STR_LEN( g_string_append_len(html, CONST_STR_LEN(
" </head>\n" " </head>\n"
" <body>\n" " <body>\n"
)); ));
@ -587,8 +587,8 @@ static GString *status_info_full(liVRequest *vr, liPlugin *p, gboolean short_inf
/* worker information, absolute values */ /* worker information, absolute values */
li_g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>Absolute stats</strong></div>\n")); g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>Absolute stats</strong></div>\n"));
li_g_string_append_len(html, CONST_STR_LEN(html_worker_th)); g_string_append_len(html, CONST_STR_LEN(html_worker_th));
#define PERCENTAGE(x, y) (y ? (x * 100 / y) : 0) #define PERCENTAGE(x, y) (y ? (x * 100 / y) : 0)
for (i = 0; i < result->len; i++) { for (i = 0; i < result->len; i++) {
@ -613,12 +613,12 @@ static GString *status_info_full(liVRequest *vr, liPlugin *p, gboolean short_inf
count_bin->str, G_GUINT64_CONSTANT(100), count_bin->str, G_GUINT64_CONSTANT(100),
count_bout->str, G_GUINT64_CONSTANT(100), count_bout->str, G_GUINT64_CONSTANT(100),
total_connections, 100); total_connections, 100);
li_g_string_append_len(html, CONST_STR_LEN(" </table>\n")); g_string_append_len(html, CONST_STR_LEN(" </table>\n"));
/* worker information, avg values */ /* worker information, avg values */
li_g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>Average stats</strong> (since start)</div>\n")); g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>Average stats</strong> (since start)</div>\n"));
li_g_string_append_len(html, CONST_STR_LEN(html_worker_th_avg)); g_string_append_len(html, CONST_STR_LEN(html_worker_th_avg));
#define PERCENTAGE(x) (sd->stat ## x ? (sd->stat ## x * 100 / total ## x) : 0) #define PERCENTAGE(x) (sd->stat ## x ? (sd->stat ## x * 100 / total ## x) : 0)
for (i = 0; i < result->len; i++) { for (i = 0; i < result->len; i++) {
@ -646,12 +646,12 @@ static GString *status_info_full(liVRequest *vr, liPlugin *p, gboolean short_inf
count_bout->str, count_bout->str,
(guint)(totals->active_cons_cum / uptime) (guint)(totals->active_cons_cum / uptime)
); );
li_g_string_append_len(html, CONST_STR_LEN(" </table>\n")); g_string_append_len(html, CONST_STR_LEN(" </table>\n"));
/* worker information, 5 seconds avg values */ /* worker information, 5 seconds avg values */
li_g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>Average stats</strong> (5 seconds)</div>\n")); g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>Average stats</strong> (5 seconds)</div>\n"));
li_g_string_append_len(html, CONST_STR_LEN(html_worker_th_avg)); g_string_append_len(html, CONST_STR_LEN(html_worker_th_avg));
#define PERCENTAGE(x) (sd->stat ## x ? (sd->stat ## x * 100 / total ## x) : 0) #define PERCENTAGE(x) (sd->stat ## x ? (sd->stat ## x * 100 / total ## x) : 0)
for (i = 0; i < result->len; i++) { for (i = 0; i < result->len; i++) {
@ -679,12 +679,12 @@ static GString *status_info_full(liVRequest *vr, liPlugin *p, gboolean short_inf
count_bout->str, count_bout->str,
totals->active_cons_5s totals->active_cons_5s
); );
li_g_string_append_len(html, CONST_STR_LEN(" </table>\n")); g_string_append_len(html, CONST_STR_LEN(" </table>\n"));
/* worker information, peak values */ /* worker information, peak values */
li_g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>Peak stats</strong></div>\n")); g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>Peak stats</strong></div>\n"));
li_g_string_append_len(html, CONST_STR_LEN(html_worker_th_avg)); g_string_append_len(html, CONST_STR_LEN(html_worker_th_avg));
for (i = 0; i < result->len; i++) { for (i = 0; i < result->len; i++) {
mod_status_wrk_data *sd = g_ptr_array_index(result, i); mod_status_wrk_data *sd = g_ptr_array_index(result, i);
@ -710,11 +710,11 @@ static GString *status_info_full(liVRequest *vr, liPlugin *p, gboolean short_inf
count_bout->str, count_bout->str,
totals->peak.active_cons totals->peak.active_cons
); );
li_g_string_append_len(html, CONST_STR_LEN(" </table>\n")); g_string_append_len(html, CONST_STR_LEN(" </table>\n"));
/* connection counts */ /* connection counts */
li_g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>Connections</strong> (states, sum)</div>\n")); g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>Connections</strong> (states, sum)</div>\n"));
g_string_append_printf(html, html_connections_sum, g_string_append_printf(html, html_connections_sum,
connection_count[LI_CON_STATE_DEAD] + connection_count[LI_CON_STATE_CLOSE], connection_count[LI_CON_STATE_DEAD] + connection_count[LI_CON_STATE_CLOSE],
connection_count[LI_CON_STATE_REQUEST_START], connection_count[LI_CON_STATE_READ_REQUEST_HEADER], connection_count[LI_CON_STATE_REQUEST_START], connection_count[LI_CON_STATE_READ_REQUEST_HEADER],
@ -723,7 +723,7 @@ static GString *status_info_full(liVRequest *vr, liPlugin *p, gboolean short_inf
); );
/* response status codes */ /* response status codes */
li_g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>HTTP Status codes</strong> (sum)</div>\n")); g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>HTTP Status codes</strong> (sum)</div>\n"));
g_string_append_printf(html, html_status_codes, mod_status_response_codes[0], mod_status_response_codes[1], g_string_append_printf(html, html_status_codes, mod_status_response_codes[0], mod_status_response_codes[1],
mod_status_response_codes[2], mod_status_response_codes[3], mod_status_response_codes[4] mod_status_response_codes[2], mod_status_response_codes[3], mod_status_response_codes[4]
); );
@ -743,8 +743,8 @@ static GString *status_info_full(liVRequest *vr, liPlugin *p, gboolean short_inf
req_len = g_string_sized_new(10); req_len = g_string_sized_new(10);
resp_len = g_string_sized_new(10); resp_len = g_string_sized_new(10);
li_g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>Active connections</strong></div>\n")); g_string_append_len(html, CONST_STR_LEN("<div class=\"title\"><strong>Active connections</strong></div>\n"));
li_g_string_append_len(html, CONST_STR_LEN(html_connections_th)); g_string_append_len(html, CONST_STR_LEN(html_connections_th));
for (i = 0; i < result->len; i++) { for (i = 0; i < result->len; i++) {
mod_status_wrk_data *sd = g_ptr_array_index(result, i); mod_status_wrk_data *sd = g_ptr_array_index(result, i);
@ -780,7 +780,7 @@ static GString *status_info_full(liVRequest *vr, liPlugin *p, gboolean short_inf
} }
} }
li_g_string_append_len(html, CONST_STR_LEN(" </table>\n")); g_string_append_len(html, CONST_STR_LEN(" </table>\n"));
g_string_free(ts_started, TRUE); g_string_free(ts_started, TRUE);
g_string_free(ts_timeout, TRUE); g_string_free(ts_timeout, TRUE);
@ -792,7 +792,7 @@ static GString *status_info_full(liVRequest *vr, liPlugin *p, gboolean short_inf
g_string_free(resp_len, TRUE); g_string_free(resp_len, TRUE);
} }
li_g_string_append_len(html, CONST_STR_LEN( g_string_append_len(html, CONST_STR_LEN(
" </body>\n" " </body>\n"
"</html>\n" "</html>\n"
)); ));
@ -813,59 +813,59 @@ static GString *status_info_plain(liVRequest *vr, guint uptime, liStatistics *to
html = g_string_sized_new(1024 - 1); html = g_string_sized_new(1024 - 1);
/* absolute values */ /* absolute values */
li_g_string_append_len(html, CONST_STR_LEN("# Absolute Values\nuptime: ")); g_string_append_len(html, CONST_STR_LEN("# Absolute Values\nuptime: "));
li_string_append_int(html, (gint64)uptime); li_string_append_int(html, (gint64)uptime);
li_g_string_append_len(html, CONST_STR_LEN("\nmemory_usage: ")); g_string_append_len(html, CONST_STR_LEN("\nmemory_usage: "));
li_string_append_int(html, li_memory_usage()); li_string_append_int(html, li_memory_usage());
li_g_string_append_len(html, CONST_STR_LEN("\nrequests_abs: ")); g_string_append_len(html, CONST_STR_LEN("\nrequests_abs: "));
li_string_append_int(html, totals->requests); li_string_append_int(html, totals->requests);
li_g_string_append_len(html, CONST_STR_LEN("\ntraffic_out_abs: ")); g_string_append_len(html, CONST_STR_LEN("\ntraffic_out_abs: "));
li_string_append_int(html, totals->bytes_out); li_string_append_int(html, totals->bytes_out);
li_g_string_append_len(html, CONST_STR_LEN("\ntraffic_in_abs: ")); g_string_append_len(html, CONST_STR_LEN("\ntraffic_in_abs: "));
li_string_append_int(html, totals->bytes_in); li_string_append_int(html, totals->bytes_in);
li_g_string_append_len(html, CONST_STR_LEN("\nconnections_abs: ")); g_string_append_len(html, CONST_STR_LEN("\nconnections_abs: "));
li_string_append_int(html, total_connections); li_string_append_int(html, total_connections);
/* average since start */ /* average since start */
li_g_string_append_len(html, CONST_STR_LEN("\n\n# Average Values (since start)\nrequests_avg: ")); g_string_append_len(html, CONST_STR_LEN("\n\n# Average Values (since start)\nrequests_avg: "));
li_string_append_int(html, totals->requests / uptime); li_string_append_int(html, totals->requests / uptime);
li_g_string_append_len(html, CONST_STR_LEN("\ntraffic_out_avg: ")); g_string_append_len(html, CONST_STR_LEN("\ntraffic_out_avg: "));
li_string_append_int(html, totals->bytes_out / uptime); li_string_append_int(html, totals->bytes_out / uptime);
li_g_string_append_len(html, CONST_STR_LEN("\ntraffic_in_avg: ")); g_string_append_len(html, CONST_STR_LEN("\ntraffic_in_avg: "));
li_string_append_int(html, totals->bytes_in / uptime); li_string_append_int(html, totals->bytes_in / uptime);
li_g_string_append_len(html, CONST_STR_LEN("\nconnections_avg: ")); g_string_append_len(html, CONST_STR_LEN("\nconnections_avg: "));
li_string_append_int(html, totals->active_cons_cum / uptime); li_string_append_int(html, totals->active_cons_cum / uptime);
/* average last 5 seconds */ /* average last 5 seconds */
li_g_string_append_len(html, CONST_STR_LEN("\n\n# Average Values (5 seconds)\nrequests_avg_5sec: ")); g_string_append_len(html, CONST_STR_LEN("\n\n# Average Values (5 seconds)\nrequests_avg_5sec: "));
li_string_append_int(html, totals->requests_5s_diff / 5); li_string_append_int(html, totals->requests_5s_diff / 5);
li_g_string_append_len(html, CONST_STR_LEN("\ntraffic_out_avg_5sec: ")); g_string_append_len(html, CONST_STR_LEN("\ntraffic_out_avg_5sec: "));
li_string_append_int(html, totals->bytes_out_5s_diff / 5); li_string_append_int(html, totals->bytes_out_5s_diff / 5);
li_g_string_append_len(html, CONST_STR_LEN("\ntraffic_in_avg_5sec: ")); g_string_append_len(html, CONST_STR_LEN("\ntraffic_in_avg_5sec: "));
li_string_append_int(html, totals->bytes_in_5s_diff / 5); li_string_append_int(html, totals->bytes_in_5s_diff / 5);
li_g_string_append_len(html, CONST_STR_LEN("\nconnections_avg_5sec: ")); g_string_append_len(html, CONST_STR_LEN("\nconnections_avg_5sec: "));
li_string_append_int(html, totals->active_cons_5s / 5); li_string_append_int(html, totals->active_cons_5s / 5);
/* connection states */ /* connection states */
li_g_string_append_len(html, CONST_STR_LEN("\n\n# Connection States\nconnection_state_start: ")); g_string_append_len(html, CONST_STR_LEN("\n\n# Connection States\nconnection_state_start: "));
li_string_append_int(html, connection_count[LI_CON_STATE_REQUEST_START]); li_string_append_int(html, connection_count[LI_CON_STATE_REQUEST_START]);
li_g_string_append_len(html, CONST_STR_LEN("\nconnection_state_read_header: ")); g_string_append_len(html, CONST_STR_LEN("\nconnection_state_read_header: "));
li_string_append_int(html, connection_count[LI_CON_STATE_READ_REQUEST_HEADER]); li_string_append_int(html, connection_count[LI_CON_STATE_READ_REQUEST_HEADER]);
li_g_string_append_len(html, CONST_STR_LEN("\nconnection_state_handle_request: ")); g_string_append_len(html, CONST_STR_LEN("\nconnection_state_handle_request: "));
li_string_append_int(html, connection_count[LI_CON_STATE_HANDLE_MAINVR]); li_string_append_int(html, connection_count[LI_CON_STATE_HANDLE_MAINVR]);
li_g_string_append_len(html, CONST_STR_LEN("\nconnection_state_write_response: ")); g_string_append_len(html, CONST_STR_LEN("\nconnection_state_write_response: "));
li_string_append_int(html, connection_count[LI_CON_STATE_WRITE]); li_string_append_int(html, connection_count[LI_CON_STATE_WRITE]);
li_g_string_append_len(html, CONST_STR_LEN("\nconnection_state_keep_alive: ")); g_string_append_len(html, CONST_STR_LEN("\nconnection_state_keep_alive: "));
li_string_append_int(html, connection_count[LI_CON_STATE_KEEP_ALIVE]); li_string_append_int(html, connection_count[LI_CON_STATE_KEEP_ALIVE]);
li_g_string_append_len(html, CONST_STR_LEN("\nconnection_state_upgraded: ")); g_string_append_len(html, CONST_STR_LEN("\nconnection_state_upgraded: "));
li_string_append_int(html, connection_count[LI_CON_STATE_UPGRADED]); li_string_append_int(html, connection_count[LI_CON_STATE_UPGRADED]);
/* status cpdes */ /* status cpdes */
li_g_string_append_len(html, CONST_STR_LEN("\n\n# Status Codes (since start)\nstatus_1xx: ")); g_string_append_len(html, CONST_STR_LEN("\n\n# Status Codes (since start)\nstatus_1xx: "));
li_string_append_int(html, mod_status_response_codes[0]); li_string_append_int(html, mod_status_response_codes[0]);
li_g_string_append_len(html, CONST_STR_LEN("\nstatus_2xx: ")); g_string_append_len(html, CONST_STR_LEN("\nstatus_2xx: "));
li_string_append_int(html, mod_status_response_codes[1]); li_string_append_int(html, mod_status_response_codes[1]);
li_g_string_append_len(html, CONST_STR_LEN("\nstatus_3xx: ")); g_string_append_len(html, CONST_STR_LEN("\nstatus_3xx: "));
li_string_append_int(html, mod_status_response_codes[2]); li_string_append_int(html, mod_status_response_codes[2]);
li_g_string_append_len(html, CONST_STR_LEN("\nstatus_4xx: ")); g_string_append_len(html, CONST_STR_LEN("\nstatus_4xx: "));
li_string_append_int(html, mod_status_response_codes[3]); li_string_append_int(html, mod_status_response_codes[3]);
li_g_string_append_len(html, CONST_STR_LEN("\nstatus_5xx: ")); g_string_append_len(html, CONST_STR_LEN("\nstatus_5xx: "));
li_string_append_int(html, mod_status_response_codes[4]); li_string_append_int(html, mod_status_response_codes[4]);
li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain")); li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain"));
@ -880,31 +880,31 @@ static GString *status_info_auto(liVRequest *vr, guint uptime, liStatistics *tot
html = g_string_sized_new(1024 - 1); html = g_string_sized_new(1024 - 1);
/* absolute values */ /* absolute values */
li_g_string_append_len(html, CONST_STR_LEN("Total Accesses: ")); g_string_append_len(html, CONST_STR_LEN("Total Accesses: "));
li_string_append_int(html, totals->requests); li_string_append_int(html, totals->requests);
li_g_string_append_len(html, CONST_STR_LEN("\nTotal kBytes: ")); g_string_append_len(html, CONST_STR_LEN("\nTotal kBytes: "));
li_string_append_int(html, totals->bytes_out / 1024); li_string_append_int(html, totals->bytes_out / 1024);
li_g_string_append_len(html, CONST_STR_LEN("\nUptime: ")); g_string_append_len(html, CONST_STR_LEN("\nUptime: "));
li_string_append_int(html, (gint64)uptime); li_string_append_int(html, (gint64)uptime);
/* connection states */ /* connection states */
li_g_string_append_len(html, CONST_STR_LEN("\nBusyServers: ")); g_string_append_len(html, CONST_STR_LEN("\nBusyServers: "));
li_string_append_int(html, connection_count[3]+connection_count[4]+connection_count[5]+connection_count[6]+connection_count[7]); li_string_append_int(html, connection_count[3]+connection_count[4]+connection_count[5]+connection_count[6]+connection_count[7]);
li_g_string_append_len(html, CONST_STR_LEN("\nIdleServers: ")); g_string_append_len(html, CONST_STR_LEN("\nIdleServers: "));
li_string_append_int(html, connection_count[0]+connection_count[1]+connection_count[2]); li_string_append_int(html, connection_count[0]+connection_count[1]+connection_count[2]);
/* average since start */ /* average since start */
li_g_string_append_len(html, CONST_STR_LEN("\nTraffic: ")); g_string_append_len(html, CONST_STR_LEN("\nTraffic: "));
li_string_append_int(html, totals->bytes_out / uptime); li_string_append_int(html, totals->bytes_out / uptime);
/* average last 5 seconds */ /* average last 5 seconds */
li_g_string_append_len(html, CONST_STR_LEN("\nTraffic5s: ")); g_string_append_len(html, CONST_STR_LEN("\nTraffic5s: "));
li_string_append_int(html, totals->bytes_out_5s_diff / 5); li_string_append_int(html, totals->bytes_out_5s_diff / 5);
/* output scoreboard */ /* output scoreboard */
li_g_string_append_len(html, CONST_STR_LEN("\nScoreboard: ")); g_string_append_len(html, CONST_STR_LEN("\nScoreboard: "));
for (i = 0; i <= LI_CON_STATE_LAST; i++) { for (i = 0; i <= LI_CON_STATE_LAST; i++) {
for (j = 0; j < connection_count[i]; j++) { for (j = 0; j < connection_count[i]; j++) {
g_string_append_c(html, liConnectionState_short[i]); g_string_append_c(html, liConnectionState_short[i]);
} }
} }
li_g_string_append_len(html, CONST_STR_LEN("\n")); g_string_append_len(html, CONST_STR_LEN("\n"));
li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain")); li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain"));
@ -1017,7 +1017,7 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
html = g_string_sized_new(8*1024-1); html = g_string_sized_new(8*1024-1);
tmp_str = g_string_sized_new(10); tmp_str = g_string_sized_new(10);
li_g_string_append_len(html, CONST_STR_LEN(html_header)); g_string_append_len(html, CONST_STR_LEN(html_header));
/* auto refresh */ /* auto refresh */
{ {
@ -1026,12 +1026,12 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
gchar c; gchar c;
if (li_querystring_find(vr->request.uri.query, CONST_STR_LEN("refresh"), &val, &len)) { if (li_querystring_find(vr->request.uri.query, CONST_STR_LEN("refresh"), &val, &len)) {
li_g_string_append_len(html, CONST_STR_LEN("<meta http-equiv=\"refresh\" content=\"")); g_string_append_len(html, CONST_STR_LEN("<meta http-equiv=\"refresh\" content=\""));
/* temp char swap */ /* temp char swap */
c = val[len]; val[len] = '\0'; c = val[len]; val[len] = '\0';
li_string_encode_append(val, html, LI_ENCODING_HTML); li_string_encode_append(val, html, LI_ENCODING_HTML);
val[len] = c; val[len] = c;
li_g_string_append_len(html, CONST_STR_LEN("\">\n")); g_string_append_len(html, CONST_STR_LEN("\">\n"));
} }
} }
@ -1040,14 +1040,14 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
GString* css = _OPTIONPTR(vr, p, 0).string; GString* css = _OPTIONPTR(vr, p, 0).string;
if (!css || !css->len) /* default css */ if (!css || !css->len) /* default css */
li_g_string_append_len(html, CONST_STR_LEN(css_default)); g_string_append_len(html, CONST_STR_LEN(css_default));
else if (g_str_equal(css->str, "blue")) /* blue css */ else if (g_str_equal(css->str, "blue")) /* blue css */
li_g_string_append_len(html, CONST_STR_LEN(css_blue)); g_string_append_len(html, CONST_STR_LEN(css_blue));
else /* external css */ else /* external css */
g_string_append_printf(html, " <link rel=\"stylesheet\" rev=\"stylesheet\" href=\"%s\" media=\"screen\" />\n", css->str); g_string_append_printf(html, " <link rel=\"stylesheet\" rev=\"stylesheet\" href=\"%s\" media=\"screen\" />\n", css->str);
} }
li_g_string_append_len(html, CONST_STR_LEN( g_string_append_len(html, CONST_STR_LEN(
" </head>\n" " </head>\n"
" <body>\n" " <body>\n"
)); ));
@ -1093,7 +1093,7 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
slim_fd = slim_core = "unknown"; slim_fd = slim_core = "unknown";
#endif #endif
li_g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>Server info</strong></div>\n")); g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>Server info</strong></div>\n"));
g_string_append_printf(html, html_server_info, g_string_append_printf(html, html_server_info,
g_get_host_name(), g_get_user_name(), getuid(), li_event_loop_backend_string(&vr->wrk->loop), g_get_host_name(), g_get_user_name(), getuid(), li_event_loop_backend_string(&vr->wrk->loop),
slim_fd, g_atomic_int_get(&vr->wrk->srv->max_connections), slim_core, (guint64) vr->wrk->srv->io_timeout slim_fd, g_atomic_int_get(&vr->wrk->srv->max_connections), slim_core, (guint64) vr->wrk->srv->io_timeout
@ -1106,8 +1106,8 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
/* library info */ /* library info */
{ {
li_g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>Libraries</strong></div>\n")); g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>Libraries</strong></div>\n"));
li_g_string_append_len(html, CONST_STR_LEN(html_libinfo_th)); g_string_append_len(html, CONST_STR_LEN(html_libinfo_th));
g_string_truncate(tmp_str, 0); g_string_truncate(tmp_str, 0);
g_string_append_printf(tmp_str, "%u.%u.%u", glib_major_version, glib_minor_version, glib_micro_version); g_string_append_printf(tmp_str, "%u.%u.%u", glib_major_version, glib_minor_version, glib_micro_version);
@ -1129,15 +1129,15 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
vr->wrk->tmp_str->str vr->wrk->tmp_str->str
); );
li_g_string_append_len(html, CONST_STR_LEN(" </table>\n")); g_string_append_len(html, CONST_STR_LEN(" </table>\n"));
} }
/* libev info */ /* libev info */
{ {
guint i; guint i;
li_g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>libev backends</strong></div>\n")); g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>libev backends</strong></div>\n"));
li_g_string_append_len(html, CONST_STR_LEN(html_libev_th)); g_string_append_len(html, CONST_STR_LEN(html_libev_th));
/* supported backend, aka compiled in */ /* supported backend, aka compiled in */
i = ev_supported_backends(); i = ev_supported_backends();
@ -1161,7 +1161,7 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
i & EVBACKEND_PORT ? "yes" : "no" i & EVBACKEND_PORT ? "yes" : "no"
); );
li_g_string_append_len(html, CONST_STR_LEN(" </table>\n")); g_string_append_len(html, CONST_STR_LEN(" </table>\n"));
} }
/* list modules */ /* list modules */
@ -1171,8 +1171,8 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
GHashTableIter iter; GHashTableIter iter;
GArray *list = g_array_sized_new(FALSE, FALSE, sizeof(gchar*), g_hash_table_size(vr->wrk->srv->plugins)); GArray *list = g_array_sized_new(FALSE, FALSE, sizeof(gchar*), g_hash_table_size(vr->wrk->srv->plugins));
li_g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>Loaded modules</strong></div>\n")); g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>Loaded modules</strong></div>\n"));
li_g_string_append_len(html, CONST_STR_LEN(" <table cellspacing=\"0\">\n")); g_string_append_len(html, CONST_STR_LEN(" <table cellspacing=\"0\">\n"));
g_hash_table_iter_init(&iter, vr->wrk->srv->plugins); g_hash_table_iter_init(&iter, vr->wrk->srv->plugins);
@ -1185,11 +1185,11 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
for (i = 1; i < list->len; i++) { for (i = 1; i < list->len; i++) {
if (col == 0) { if (col == 0) {
li_g_string_append_len(html, CONST_STR_LEN(" <tr>\n")); g_string_append_len(html, CONST_STR_LEN(" <tr>\n"));
col++; col++;
} }
else if (col == 5) { else if (col == 5) {
li_g_string_append_len(html, CONST_STR_LEN(" </tr>\n")); g_string_append_len(html, CONST_STR_LEN(" </tr>\n"));
col = 0; col = 0;
continue; continue;
} else { } else {
@ -1201,12 +1201,12 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
if (col) { if (col) {
for (i = 5 - col; i; i--) for (i = 5 - col; i; i--)
li_g_string_append_len(html, CONST_STR_LEN(" <td></td>\n")); g_string_append_len(html, CONST_STR_LEN(" <td></td>\n"));
li_g_string_append_len(html, CONST_STR_LEN(" </tr>\n")); g_string_append_len(html, CONST_STR_LEN(" </tr>\n"));
} }
li_g_string_append_len(html, CONST_STR_LEN(" </table>\n")); g_string_append_len(html, CONST_STR_LEN(" </table>\n"));
g_array_free(list, TRUE); g_array_free(list, TRUE);
} }
@ -1216,19 +1216,19 @@ static liHandlerResult status_info_runtime(liVRequest *vr, liPlugin *p) {
gchar **e; gchar **e;
gchar **env = g_listenv(); gchar **env = g_listenv();
li_g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>Process environment</strong></div>\n")); g_string_append_len(html, CONST_STR_LEN(" <div class=\"title\"><strong>Process environment</strong></div>\n"));
li_g_string_append_len(html, CONST_STR_LEN(" <table cellspacing=\"0\">\n")); g_string_append_len(html, CONST_STR_LEN(" <table cellspacing=\"0\">\n"));
for (e = env; *e; e++) { for (e = env; *e; e++) {
g_string_append_printf(html, " <tr><td class=\"left\">%s</td><td class=\"left\">%s</td></tr>\n", *e, getenv(*e)); g_string_append_printf(html, " <tr><td class=\"left\">%s</td><td class=\"left\">%s</td></tr>\n", *e, getenv(*e));
} }
li_g_string_append_len(html, CONST_STR_LEN(" </table>\n")); g_string_append_len(html, CONST_STR_LEN(" </table>\n"));
g_strfreev(env); g_strfreev(env);
} }
li_g_string_append_len(html, CONST_STR_LEN( g_string_append_len(html, CONST_STR_LEN(
" </body>\n" " </body>\n"
"</html>\n" "</html>\n"
)); ));

View File

@ -103,10 +103,10 @@ static liHandlerResult userdir(liVRequest *vr, gpointer param, gpointer *context
part = &g_array_index(parts, userdir_part, i); part = &g_array_index(parts, userdir_part, i);
switch (part->type) { switch (part->type) {
case USERDIR_PART_STRING: case USERDIR_PART_STRING:
li_g_string_append_len(vr->physical.doc_root, GSTR_LEN(part->data.str)); g_string_append_len(vr->physical.doc_root, GSTR_LEN(part->data.str));
break; break;
case USERDIR_PART_USERNAME: case USERDIR_PART_USERNAME:
li_g_string_append_len(vr->physical.doc_root, username, username_len); g_string_append_len(vr->physical.doc_root, username, username_len);
has_username = TRUE; has_username = TRUE;
break; break;
case USERDIR_PART_LETTER: case USERDIR_PART_LETTER:
@ -120,7 +120,7 @@ static liHandlerResult userdir(liVRequest *vr, gpointer param, gpointer *context
/* pattern without username, append it. /usr/web/ => /usr/web/user/ */ /* pattern without username, append it. /usr/web/ => /usr/web/user/ */
if (vr->physical.doc_root->str[vr->physical.doc_root->len-1] != G_DIR_SEPARATOR) if (vr->physical.doc_root->str[vr->physical.doc_root->len-1] != G_DIR_SEPARATOR)
g_string_append_c(vr->physical.doc_root, G_DIR_SEPARATOR); g_string_append_c(vr->physical.doc_root, G_DIR_SEPARATOR);
li_g_string_append_len(vr->physical.doc_root, username, username_len); g_string_append_len(vr->physical.doc_root, username, username_len);
} }
/* ensure that docroot is ending with a slash */ /* ensure that docroot is ending with a slash */
@ -129,15 +129,15 @@ static liHandlerResult userdir(liVRequest *vr, gpointer param, gpointer *context
/* build physical path: docroot + uri.path */ /* build physical path: docroot + uri.path */
g_string_truncate(vr->physical.path, 0); g_string_truncate(vr->physical.path, 0);
li_g_string_append_len(vr->physical.path, GSTR_LEN(vr->physical.doc_root)); g_string_append_len(vr->physical.path, GSTR_LEN(vr->physical.doc_root));
li_g_string_append_len(vr->physical.path, username + username_len, vr->request.uri.path->str - username - username_len); g_string_append_len(vr->physical.path, username + username_len, vr->request.uri.path->str - username - username_len);
/* rewrite request path to skip username */ /* rewrite request path to skip username */
g_string_truncate(vr->wrk->tmp_str, 0); g_string_truncate(vr->wrk->tmp_str, 0);
li_g_string_append_len(vr->wrk->tmp_str, username + username_len, vr->request.uri.path->str - username - username_len); g_string_append_len(vr->wrk->tmp_str, username + username_len, vr->request.uri.path->str - username - username_len);
g_string_truncate(vr->request.uri.path, 0); g_string_truncate(vr->request.uri.path, 0);
if (vr->wrk->tmp_str->len) if (vr->wrk->tmp_str->len)
li_g_string_append_len(vr->request.uri.path, GSTR_LEN(vr->wrk->tmp_str)); g_string_append_len(vr->request.uri.path, GSTR_LEN(vr->wrk->tmp_str));
else else
g_string_append_c(vr->request.uri.path, G_DIR_SEPARATOR); g_string_append_c(vr->request.uri.path, G_DIR_SEPARATOR);

View File

@ -366,7 +366,7 @@ INLINE liSSLClientHelloParserResult _li_ssl_client_hello_parse(liSSLClientHelloP
case 5: case 5:
if (0 == context->sni_type && !context->sni_complete) { if (0 == context->sni_type && !context->sni_complete) {
guint take = MIN(context->sni_hostname_remaining, (guint) (extension_pe - p)); guint take = MIN(context->sni_hostname_remaining, (guint) (extension_pe - p));
li_g_string_append_len(server_name, (gchar*) p, take); g_string_append_len(server_name, (gchar*) p, take);
context->sni_hostname_remaining -= take; context->sni_hostname_remaining -= take;
p += take; p += take;
if (0 == context->sni_hostname_remaining) { if (0 == context->sni_hostname_remaining) {

View File

@ -1,45 +0,0 @@
unittests = {
'Chunk-UnitTest': {
'binary': 'test-chunk',
'sources': ['test-chunk.c'],
},
'HttpRequestParser-UnitTest': {
'binary': 'test-http-request-parser',
'sources': ['test-http-request-parser.c'],
},
'IpParser-UnitTest': {
'binary': 'test-ip-parser',
'sources': ['test-ip-parser.c'],
},
'Radix-UnitTest': {
'binary': 'test-radix',
'sources': ['test-radix.c'],
},
'RangeParser-UnitTest': {
'binary': 'test-range-parser',
'sources': ['test-range-parser.c'],
},
'Utils-UnitTest': {
'binary': 'test-utils',
'sources': ['test-utils.c'],
},
}
foreach name, def: unittests
test_bin = executable(
def['binary'],
def['sources'],
include_directories: inc_dir,
dependencies: main_deps + def.get('dependencies', []),
link_with: [
lib_shared,
lib_common,
],
build_by_default: false,
)
test(
name,
test_bin,
protocol: 'tap',
)
endforeach

View File

@ -1,16 +0,0 @@
runtest_file = files('runtests.py')
test(
'http',
runtest_file,
args: [
'--angel', bin_angel.full_path(),
'--worker', bin_worker.full_path(),
'--plugindir', modules_build_dir,
],
depends: [
bin_angel,
bin_worker,
enabled_modules,
],
)

View File

@ -6,7 +6,7 @@ from pylt.requests import CurlRequest
# userI:passI for I in [1..4] with [apr-md5, crypt, plain and apr-sha] # userI:passI for I in [1..4] with [apr-md5, crypt, plain and apr-sha]
PASSWORDS = """user1:$apr1$mhpONdUp$xSRcAbK2F6hLFUzW59tzW/ PASSWORDS = """user1:$apr1$mhpONdUp$xSRcAbK2F6hLFUzW59tzW/
# user2:JTMoqfZHCS0aI user2:JTMoqfZHCS0aI
user3:pass3 user3:pass3
user4:{SHA}LbTBgR9CRYKpD41+53mVzwGNlEM= user4:{SHA}LbTBgR9CRYKpD41+53mVzwGNlEM=
""" """
@ -34,11 +34,10 @@ class TestCryptFail(CurlRequest):
AUTH = "user2:test2" AUTH = "user2:test2"
# no-prefix crypt deprecated class TestCryptSuccess(CurlRequest):
# class TestCryptSuccess(CurlRequest): URL = "/test.txt"
# URL = "/test.txt" EXPECT_RESPONSE_CODE = 200
# EXPECT_RESPONSE_CODE = 200 AUTH = "user2:pass2"
# AUTH = "user2:pass2"
class TestPlainFail(CurlRequest): class TestPlainFail(CurlRequest):