Mailing List Archive

r2675 - trunk/varnish-cache/bin/varnishtest
Author: phk
Date: 2008-06-15 14:08:11 +0200 (Sun, 15 Jun 2008)
New Revision: 2675

Added:
trunk/varnish-cache/bin/varnishtest/vtc_http.c
Modified:
trunk/varnish-cache/bin/varnishtest/Makefile.am
trunk/varnish-cache/bin/varnishtest/t000.vtc
trunk/varnish-cache/bin/varnishtest/vtc.h
trunk/varnish-cache/bin/varnishtest/vtc_client.c
trunk/varnish-cache/bin/varnishtest/vtc_server.c
Log:
Add the HTTP subprocessor



Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-15 11:47:01 UTC (rev 2674)
+++ trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-15 12:08:11 UTC (rev 2675)
@@ -7,6 +7,7 @@
varnishtest_SOURCES = \
vtc.c \
vtc_client.c \
+ vtc_http.c \
vtc_server.c \
vtc_stats.c \
vtc_varnish.c \

Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 11:47:01 UTC (rev 2674)
+++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 12:08:11 UTC (rev 2675)
@@ -3,7 +3,7 @@

server s1 -listen :9080 -repeat 2 {
rxreq
- expect url == "/"
+ expect req.url == "/"
txresponse -body "0123456789"
}

@@ -12,8 +12,8 @@
client c1 -connect localhost:9080 {
txreq -url "/"
rxresponse
- expect status == 200
- expect length == 10
+ expect resp.status == 200
+ expect resp.length == 10
}

client c1 -run

Modified: trunk/varnish-cache/bin/varnishtest/vtc.h
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 11:47:01 UTC (rev 2674)
+++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 12:08:11 UTC (rev 2675)
@@ -40,3 +40,4 @@
void cmd_stats(char **av, void *priv);
void cmd_varnish(char **av, void *priv);

+void http_process(const char *spec, int sock, int client);

Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 11:47:01 UTC (rev 2674)
+++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 12:08:11 UTC (rev 2675)
@@ -84,7 +84,7 @@
assert(fd >= 0);
printf("#### Client %s connected to %s fd is %d\n",
c->name, c->connect, fd);
- sleep (1);
+ http_process(c->spec, fd, 1);
close(fd);
printf("### Client %s ending\n", c->name);


Added: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 12:08:11 UTC (rev 2675)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2006-2008 Linpro AS
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "libvarnish.h"
+#include "miniobj.h"
+
+#include "vtc.h"
+
+
+struct http {
+ unsigned magic;
+#define HTTP_MAGIC 0x2f02169c
+ int fd;
+ int client;
+};
+
+
+static struct cmds http_cmds[] = {
+ { "txreq", cmd_dump },
+ { "rxreq", cmd_dump },
+ { "txresponse", cmd_dump },
+ { "rxresponse", cmd_dump },
+ { "expect", cmd_dump },
+ { NULL, NULL }
+};
+
+void
+http_process(const char *spec, int sock, int client)
+{
+ struct http *hp;
+ char *s, *q;
+
+ ALLOC_OBJ(hp, HTTP_MAGIC);
+ hp->fd = sock;
+ hp->client = client;
+ (void)spec;
+ (void)sock;
+ (void)client;
+
+ s = strdup(spec + 1);
+ q = strchr(s, '\0');
+ assert(q > s);
+ q--;
+ assert(*q == '}');
+ *q = '\0';
+ AN(s);
+ parse_string(s, http_cmds, hp);
+}

Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 11:47:01 UTC (rev 2674)
+++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 12:08:11 UTC (rev 2675)
@@ -88,6 +88,7 @@
l = sizeof addr_s;
fd = accept(s->sock, addr, &l);
printf("#### Accepted socket %d\n", fd);
+ http_process(s->spec, fd, 0);
close(fd);
}
printf("### Server %s ending\n", s->name);