Commit 218f6cb0 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add the HTTP subprocessor



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2675 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 434afba6
......@@ -7,6 +7,7 @@ bin_PROGRAMS = varnishtest
varnishtest_SOURCES = \
vtc.c \
vtc_client.c \
vtc_http.c \
vtc_server.c \
vtc_stats.c \
vtc_varnish.c \
......
......@@ -3,7 +3,7 @@
server s1 -listen :9080 -repeat 2 {
rxreq
expect url == "/"
expect req.url == "/"
txresponse -body "0123456789"
}
......@@ -12,8 +12,8 @@ server s1 -start
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
......
......@@ -40,3 +40,4 @@ void cmd_vcl(char **av, void *priv);
void cmd_stats(char **av, void *priv);
void cmd_varnish(char **av, void *priv);
void http_process(const char *spec, int sock, int client);
......@@ -84,7 +84,7 @@ client_thread(void *priv)
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);
......
/*
* 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);
}
......@@ -88,6 +88,7 @@ server_thread(void *priv)
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);
......
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