Commit 2aa548f7 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

More complete HTTP parsing and logging.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@69 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 04f4a97c
......@@ -4,11 +4,34 @@
#define VCA_RXBUFSIZE 1024
#define VCA_ADDRBUFSIZE 32
struct sess {
int fd;
char rcv[VCA_RXBUFSIZE + 1];
/* formatted ascii client address */
char addr[VCA_ADDRBUFSIZE];
/* Receive buffer for HTTP header */
char rcv[VCA_RXBUFSIZE + 1];
unsigned rcv_len;
/* HTTP request info, points into rcv */
const char *req_b;
const char *req_e;
const char *url_b;
const char *url_e;
const char *proto_b;
const char *proto_e;
const char *hdr_b;
const char *hdr_e;
enum {
HND_Unclass,
HND_Handle,
HND_Pass
} handling;
/* Various internal stuff */
struct event *rd_e;
struct sessmem *mem;
};
......
......@@ -64,9 +64,9 @@ http_read_f(int fd, short event, void *arg)
continue;
break;
}
sp->hdr_e = p;
event_del(sp->rd_e);
HttpdAnalyze(sp);
printf("full <%s>\n", sp->rcv);
}
static void
......
......@@ -14,27 +14,60 @@
void
HttpdAnalyze(struct sess *sp)
{
const char *p, *q, *u;
const char *p, *q;
p = sp->rcv;
sp->handling = HND_Unclass;
/* First, isolate and possibly identify request type */
p = sp->req_b = sp->rcv;
if (p[0] == 'G' && p[1] == 'E' && p[2] == 'T' && p[3] == ' ') {
p += 4;
VSL(SLT_Request, sp->fd, "GET");
p = sp->req_e = p + 4;
sp->handling = HND_Handle;
} else if (p[0] == 'H' && p[1] == 'E' && p[2] == 'A' && p[3] == 'D'
&& p[4] == ' ') {
p += 5;
VSL(SLT_Request, sp->fd, "HEAD");
p = sp->req_e = p + 5;
sp->handling = HND_Handle;
} else {
for (q = p; isupper(*q); q++)
/*
* We don't bother to identify the rest, we won't handle
* them in any case
*/
for (q = p; isalpha(*q); q++)
;
VSLR(SLT_Request, sp->fd, p, q);
p = q;
p = sp->req_e = q;
sp->handling = HND_Pass;
}
VSLR(SLT_Request, sp->fd, sp->req_b, sp->req_e);
/* Next find the URI */
while (isspace(*p))
p++;
u = p;
sp->url_b = p;
while (!isspace(*p))
p++;
VSLR(SLT_URL, sp->fd, u, p);
sp->url_e = p;
VSLR(SLT_URL, sp->fd, sp->url_b, sp->url_e);
/* Finally, look for protocol, if any */
while (isspace(*p) && *p != '\n')
p++;
sp->proto_b = sp->proto_e = p;
if (*p != '\n') {
while (!isspace(*p))
p++;
sp->proto_e = p;
}
VSLR(SLT_Protocol, sp->fd, sp->proto_b, sp->proto_e);
/*
* And mark the start of headers. The end of headers
* is already set in acceptor where we detected the complete request.
*/
while (*p != '\n')
p++;
p++;
while (isspace(*p) && *p != '\n')
p++;
sp->hdr_b = p;
VSLR(SLT_Headers, sp->fd, sp->hdr_b, sp->hdr_e);
}
......@@ -13,3 +13,4 @@ SLTM(ClientAddr)
SLTM(Request)
SLTM(URL)
SLTM(Protocol)
SLTM(Headers)
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