Commit 0b3ab071 authored by Nils Goroll's avatar Nils Goroll

whitespace ocd

parent 492d8fb3
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (c) 2013 UPLEX - Nils Goroll Systemoptimierung])
AC_COPYRIGHT([Copyright (c) 2014 UPLEX - Nils Goroll Systemoptimierung])
AC_INIT([libvmod-esicookies], [master])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/vmod_esicookies.vcc)
......@@ -37,7 +37,10 @@ AC_HEADER_STDC
AC_CHECK_HEADERS([sys/stdlib.h])
# Check for python
AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build this vmod, please install python.])])
AC_CHECK_PROGS(PYTHON,
[python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 \
python],
[AC_MSG_ERROR([Python is needed to build this vmod.])])
# Varnish source tree
AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree (mandatory)])
......@@ -53,11 +56,13 @@ AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h],
# Check that varnishtest is built in the varnish source directory
AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest],
[],
[AC_MSG_FAILURE([Can't find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])]
[AC_MSG_FAILURE([Can't find "$VARNISHSRC/bin/varnishtest/varnishtest". \
Please run a build from your varnish source])]
)
# vmod installation dir
AC_ARG_VAR([VMODDIR], [vmod installation directory @<:@LIBDIR/varnish/vmods@:>@])
AC_ARG_VAR([VMODDIR], [vmod installation directory \
@<:@LIBDIR/varnish/vmods@:>@])
if test "x$VMODDIR" = x; then
VMODDIR=`pkg-config --variable=vmoddir varnishapi`
if test "x$VMODDIR" = x; then
......@@ -66,29 +71,48 @@ if test "x$VMODDIR" = x; then
fi
# This corresponds to FreeBSD's WARNS level 6
DEVELOPER_CFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wformat"
DEVELOPER_CFLAGS="-Wall -Wstrict-prototypes \
-Wmissing-prototypes \
-Wpointer-arith \
-Wreturn-type \
-Wcast-qual \
-Wwrite-strings \
-Wswitch \
-Wshadow \
-Wcast-align \
-Wunused-parameter \
-Wchar-subscripts \
-Winline \
-Wnested-externs \
-Wredundant-decls -Wformat"
# Additional flags for GCC 4
EXTRA_DEVELOPER_CFLAGS="-Wextra -Wno-missing-field-initializers -Wno-sign-compare"
EXTRA_DEVELOPER_CFLAGS="-Wextra \
-Wno-missing-field-initializers \
-Wno-sign-compare"
# --enable-developer-warnings
AC_ARG_ENABLE(developer-warnings,
AS_HELP_STRING([--enable-developer-warnings],[enable strict warnings (default is NO)]),
AS_HELP_STRING([--enable-developer-warnings],
[enable strict warnings (default is NO)]),
CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}")
# --enable-debugging-symbols
AC_ARG_ENABLE(debugging-symbols,
AS_HELP_STRING([--enable-debugging-symbols],[enable debugging symbols (default is NO)]),
AS_HELP_STRING([--enable-debugging-symbols],
[enable debugging symbols (default is NO)]),
CFLAGS="${CFLAGS} -O0 -g -fno-inline")
# --enable-diagnostics
AC_ARG_ENABLE(diagnostics,
AS_HELP_STRING([--enable-diagnostics],[enable run-time diagnostics (default is NO)]),
AS_HELP_STRING([--enable-diagnostics],
[enable run-time diagnostics (default is NO)]),
CFLAGS="${CFLAGS} -DDIAGNOSTICS")
# --enable-extra-developer-warnings
AC_ARG_ENABLE(extra-developer-warnings,
AS_HELP_STRING([--enable-extra-developer-warnings],[enable even stricter warnings (default is NO)]),
AS_HELP_STRING([--enable-extra-developer-warnings],
[enable even stricter warnings (default is NO)]),
[],
[enable_extra_developer_warnings=no])
......@@ -104,7 +128,8 @@ fi
# --enable-stack-protector
AC_ARG_ENABLE(stack-protector,
AS_HELP_STRING([--enable-stack-protector],[enable stack protector (default is NO)]),
AS_HELP_STRING([--enable-stack-protector],
[enable stack protector (default is NO)]),
[],
[enable_stack_protector=no])
......
AM_CPPFLAGS = \
-I$(VARNISHSRC)/include \
-I$(VARNISHSRC)/bin/varnishd
......@@ -10,7 +9,8 @@ vmod_LTLIBRARIES = libvmod_esicookies.la
vmod_srcdir = $(top_srcdir)/src
vmodtool = $(VARNISHSRC)/lib/libvmod_std/vmod.py
libvmod_esicookies_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared
libvmod_esicookies_la_LDFLAGS = $(AM_LDFLAGS) \
-module -export-dynamic -avoid-version -shared
libvmod_esicookies_la_SOURCES = \
vmod_esicookies.c
......@@ -19,7 +19,9 @@ nodist_libvmod_esicookies_la_SOURCES = \
vcc_if.c \
vcc_if.h
# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build
# BUILT_SOURCES is only a hack and dependency tracking does not help
# for the first build
vmod_esicookies.lo: vcc_if.h
vcc_if.c vcc_if.h: $(vmodtool) $(vmod_srcdir)/vmod_esicookies.vcc
......@@ -39,4 +41,3 @@ EXTRA_DIST = \
$(VMOD_TESTS)
CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h
......@@ -14,9 +14,7 @@ server s1 {
rxreq
expect req.url == "/included1"
expect req.http.Cookie == "fromclient="
txresp -body {
Included file
}
txresp -body {Included file}
# cookie with name but no equals sign or value from client
rxreq
......@@ -31,9 +29,7 @@ server s1 {
rxreq
expect req.url == "/included2"
expect req.http.Cookie == "fromclient"
txresp -body {
Included file
}
txresp -body {Included file}
# empty cookie header from client
rxreq
......@@ -48,9 +44,7 @@ server s1 {
rxreq
expect req.url == "/included3"
expect req.http.Cookie == ""
txresp -body {
Included file
}
txresp -body {Included file}
# cookie with equals sign and value but no name from client
rxreq
......@@ -65,9 +59,7 @@ server s1 {
rxreq
expect req.url == "/included4"
expect req.http.Cookie == "=1"
txresp -body {
Included file
}
txresp -body {Included file}
# cookie with empty value from response
rxreq
......@@ -83,9 +75,7 @@ server s1 {
rxreq
expect req.url == "/included5"
expect req.http.Cookie == "fromclient=1"
txresp -body {
Included file
}
txresp -body {Included file}
# Set-Cookie response with name but no equals sign or value
rxreq
......@@ -101,9 +91,7 @@ server s1 {
rxreq
expect req.url == "/included6"
expect req.http.Cookie == "fromclient=1"
txresp -body {
Included file
}
txresp -body {Included file}
# empty Set-Cookie response
rxreq
......@@ -119,9 +107,7 @@ server s1 {
rxreq
expect req.url == "/included7"
expect req.http.Cookie == "fromclient=1"
txresp -body {
Included file
}
txresp -body {Included file}
# Set-Cookie response with equals sign and value but no name
rxreq
......@@ -137,9 +123,7 @@ server s1 {
rxreq
expect req.url == "/included8"
expect req.http.Cookie == "fromclient=1"
txresp -body {
Included file
}
txresp -body {Included file}
} -start
varnish v1 -vcl+backend {
......@@ -161,53 +145,59 @@ client c1 {
# cookie with empty value from client
txreq -url "/includer1" -hdr "Cookie: fromclient="
rxresp
expect resp.body == "\n <html>\n Before include\n \n Included file\n \n After include\n "
expect resp.bodylen == 149
expect resp.body == {
<html>
Before include
Included file
After include
}
expect resp.bodylen == 60
expect resp.http.X-Err == "Invalid argument"
# cookie with name but no equals sign or value from client
txreq -url "/includer2" -hdr "Cookie: fromclient"
rxresp
expect resp.bodylen == 149
expect resp.bodylen == 60
expect resp.http.X-Err == "Invalid argument"
# empty cookie header from client
txreq -url "/includer3" -hdr "Cookie:"
rxresp
expect resp.bodylen == 149
expect resp.bodylen == 60
expect resp.http.X-Err == "Invalid argument"
# cookie with equals sign and value but no name from client
txreq -url "/includer4" -hdr "Cookie: =1"
rxresp
expect resp.bodylen == 149
expect resp.bodylen == 60
expect resp.http.X-Err == "Invalid argument"
# Set-Cookie response with empty value
txreq -url "/includer5" -hdr "Cookie: fromclient=1"
rxresp
expect resp.bodylen == 149
expect resp.bodylen == 60
expect resp.http.Set-Cookie == "fromresponse="
expect resp.http.X-Err == "Invalid argument"
# Set-Cookie response with name but no equals sign or value
txreq -url "/includer6" -hdr "Cookie: fromclient=1"
rxresp
expect resp.bodylen == 149
expect resp.bodylen == 60
expect resp.http.Set-Cookie == "fromresponse"
expect resp.http.X-Err == "Invalid argument"
# empty Set-Cookie response
txreq -url "/includer7" -hdr "Cookie: fromclient=1"
rxresp
expect resp.bodylen == 149
expect resp.bodylen == 60
expect resp.http.Set-Cookie == ""
expect resp.http.X-Err == "Invalid argument"
# Set-Cookie response with equals sign and value but no name
txreq -url "/includer8" -hdr "Cookie: fromclient=1"
rxresp
expect resp.bodylen == 149
expect resp.bodylen == 60
expect resp.http.Set-Cookie == "=1"
expect resp.http.X-Err == "Invalid argument"
} -run
/*-
* Copyright (c) 2013 UPLEX Nils Goroll Systemoptimierung
* Copyright (c) 2013-2014 UPLEX Nils Goroll Systemoptimierung
* All rights reserved
*
* Author: Nils Goroll <nils.goroll@uplex.de>
......@@ -187,8 +187,10 @@ http0_mem_ws_alloc(struct http0_mem *m) {
AN(space);
WS_Init(&m->ws[0], "http0 ws[0]", space, HTTP0_WS_SIZE);
WS_Init(&m->ws[1], "http0 ws[1]", (space + HTTP0_WS_SIZE), HTTP0_WS_SIZE);
WS_Init(&m->ws[0], "http0 ws[0]", space,
HTTP0_WS_SIZE);
WS_Init(&m->ws[1], "http0 ws[1]", (space + HTTP0_WS_SIZE),
HTTP0_WS_SIZE);
}
static struct ws *
......@@ -360,7 +362,8 @@ vesico_analyze_cookie_header(struct sess *sp, const txt hdr,
const char *H_COOKIE = "\007Cookie:";
static const char *
vesico_write_cookie_hdr(struct sess *sp, struct http0_meta *meta, struct http *h0, struct cookiehead *cookies)
vesico_write_cookie_hdr(struct sess *sp, struct http0_meta *meta,
struct http *h0, struct cookiehead *cookies)
{
unsigned u;
char *b = NULL, *e = NULL;
......@@ -417,10 +420,14 @@ vesico_write_cookie_hdr(struct sess *sp, struct http0_meta *meta, struct http *h
return "";
}
// XXX optimize for the case where existing cookie is tail of CS and we don't change existing cookies ?
/*
* XXX TODO optimize for the case where existing cookie is tail of CS and we
* don't change existing cookies ?
*/
static const char *
vesico_to_http0(struct sess *sp, struct vmod_priv *priv, enum gethdr_e where, const char *hdr)
vesico_to_http0(struct sess *sp, struct vmod_priv *priv, enum gethdr_e where,
const char *hdr)
{
struct http0_meta *meta = priv->priv;
......@@ -452,7 +459,8 @@ vesico_to_http0(struct sess *sp, struct vmod_priv *priv, enum gethdr_e where, co
h.b++;
h.e = h0->hd[n].e;
ret = vesico_analyze_cookie_header(sp, h, &cookies, &cs);
ret = vesico_analyze_cookie_header(sp, h, &cookies,
&cs);
if (ret) {
return strerror(ret);
}
......@@ -480,7 +488,8 @@ vesico_to_http0(struct sess *sp, struct vmod_priv *priv, enum gethdr_e where, co
else
h.e = hp->hd[n].e;
ret = vesico_analyze_cookie_header(sp, h, &cookies, &cs);
ret = vesico_analyze_cookie_header(sp, h, &cookies,
&cs);
if (ret) {
return strerror(ret);
}
......@@ -495,11 +504,13 @@ vesico_to_http0(struct sess *sp, struct vmod_priv *priv, enum gethdr_e where, co
}
const char * __match_proto__()
vmod_to_http0_e(struct sess *sp, struct vmod_priv *priv, enum gethdr_e where, const char *hdr) {
vmod_to_http0_e(struct sess *sp, struct vmod_priv *priv, enum gethdr_e where,
const char *hdr) {
return (vesico_to_http0(sp, priv, where, hdr));
}
void __match_proto__()
vmod_to_http0(struct sess *sp, struct vmod_priv *priv, enum gethdr_e where, const char *hdr) {
vmod_to_http0(struct sess *sp, struct vmod_priv *priv, enum gethdr_e where,
const char *hdr) {
return (void)(vesico_to_http0(sp, priv, where, hdr));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment