void VBE_ClosedFd(void *ptr);
/* cache_httpd.c */
-void HttpdAnalyze(struct sess *sp);
+void HttpdAnalyze(struct sess *sp, int rr);
void HttpdGetHead(struct sess *sp, struct event_base *eb, sesscb_f *func);
/* cache_main.c */
/*--------------------------------------------------------------------*/
void
-HttpdAnalyze(struct sess *sp)
+HttpdAnalyze(struct sess *sp, int rr)
{
char *p, *q, *r;
memset(&sp->http, 0, sizeof sp->http);
- /* First, isolate and possibly identify request type */
- sp->http.req = sp->rcv;
- for (p = sp->rcv; isalpha(*p); p++)
- ;
- VSLR(SLT_Request, sp->fd, sp->http.req, p);
- *p++ = '\0';
+ if (rr == 1) {
+ /* First, isolate and possibly identify request type */
+ sp->http.req = sp->rcv;
+ for (p = sp->rcv; isalpha(*p); p++)
+ ;
+ VSLR(SLT_Request, sp->fd, sp->http.req, p);
+ *p++ = '\0';
- /* Next find the URI */
- while (isspace(*p))
- p++;
- sp->http.url = p;
- while (!isspace(*p))
- p++;
- VSLR(SLT_URL, sp->fd, sp->http.url, p);
- *p++ = '\0';
+ /* Next find the URI */
+ while (isspace(*p))
+ p++;
+ sp->http.url = p;
+ while (!isspace(*p))
+ p++;
+ VSLR(SLT_URL, sp->fd, sp->http.url, p);
+ *p++ = '\0';
- /* Finally, look for protocol, if any */
- while (isspace(*p) && *p != '\n')
+ /* Finally, look for protocol, if any */
+ while (isspace(*p) && *p != '\n')
+ p++;
+ sp->http.proto = p;
+ if (*p != '\n') {
+ while (!isspace(*p))
+ p++;
+ }
+ VSLR(SLT_Protocol, sp->fd, sp->http.proto, p);
+ *p++ = '\0';
+
+ while (isspace(*p) && *p != '\n')
+ p++;
p++;
- sp->http.proto = p;
- if (*p != '\n') {
+ } else {
+ /* First, protocol */
+ sp->http.proto = sp->rcv;
+ p = sp->rcv;
while (!isspace(*p))
p++;
- }
- VSLR(SLT_Protocol, sp->fd, sp->http.proto, p);
- *p++ = '\0';
+ *p++ = '\0';
+ VSLR(SLT_Protocol, sp->fd, sp->http.proto, p);
- while (isspace(*p) && *p != '\n')
+ /* Next find the status */
+ while (isspace(*p))
+ p++;
+ sp->http.status = p;
+ while (!isspace(*p))
+ p++;
+ VSLR(SLT_Status, sp->fd, sp->http.status, p);
+ *p++ = '\0';
+
+ /* Next find the response */
+ while (isspace(*p))
+ p++;
+ sp->http.response = p;
+ while (*p != '\n')
+ p++;
+ for (q = p; q > sp->http.response && isspace(q[-1]); q--)
+ continue;
+ *q = '\0';
+ VSLR(SLT_Response, sp->fd, sp->http.response, q);
p++;
+ }
- p++;
if (*p == '\r')
p++;
continue; \
}
-#define HTTPH(a, b, c, d, e, f, g) W(a ":", b, p, q, sp)
+#define HTTPH(a, b, c, d, e, f, g) \
+ if (c & rr) { \
+ W(a ":", b, p, q, sp); \
+ }
#include "http_headers.h"
#undef HTTPH
#undef W
{
HERE();
- HttpdAnalyze(sp);
+ HttpdAnalyze(sp, 2);
}
/*--------------------------------------------------------------------*/
sbuf_cat(sb, "\r\n");
#define HTTPH(a, b, c, d, e, f, g) \
do { \
- if (c && sp->http.b != NULL) { \
+ if (d && sp->http.b != NULL) { \
sbuf_cat(sb, a ": "); \
sbuf_cat(sb, sp->http.b); \
sbuf_cat(sb, "\r\n"); \
#undef HTTPH
sbuf_cat(sb, "\r\n");
sbuf_finish(sb);
- printf("REQ: <%s>\n", sbuf_data(sb));
i = write(fd, sbuf_data(sb), sbuf_len(sb));
assert(i == sbuf_len(sb));
#undef HTTPH
sbuf_cat(sb, "\r\n");
sbuf_finish(sb);
- printf("REQ: <%s>\n", sbuf_data(sb));
i = write(fd, sbuf_data(sb), sbuf_len(sb));
assert(i == sbuf_len(sb));
sp->vcl = GetVCL();
AZ(pthread_mutex_unlock(&sessmtx));
- HttpdAnalyze(sp);
+ HttpdAnalyze(sp, 1);
sp->backend = sp->vcl->default_backend;
/* Call the VCL program */
*
* a Http header name
* b session field name
- * c PassThrough handling (0=remove, 1=pass)
- * d unused
+ * c Request(1)/Response(2) bitfield
+ * d Pass header
* e unused
* f unused
* g unused
* a b c d e f g
*--------------------------------------------------------------------
*/
-HTTPH("Accept-Charset", H_Accept_Charset, 1, 0, 0, 0, 0)
-HTTPH("Accept-Encoding", H_Accept_Encoding, 1, 0, 0, 0, 0)
-HTTPH("Accept-Language", H_Accept_Language, 1, 0, 0, 0, 0)
-HTTPH("Accept", H_Accept, 1, 0, 0, 0, 0)
-HTTPH("Authorization", H_Authorization, 1, 0, 0, 0, 0)
-HTTPH("Connection", H_Connection, 0, 0, 0, 0, 0)
-HTTPH("Expect", H_Expect, 1, 0, 0, 0, 0)
-HTTPH("From", H_From, 1, 0, 0, 0, 0)
-HTTPH("Host", H_Host, 1, 0, 0, 0, 0)
-HTTPH("If-Match", H_If_Match, 1, 0, 0, 0, 0)
-HTTPH("If-Modified-Since", H_If_Modified_Since, 1, 0, 0, 0, 0)
-HTTPH("If-None-Match", H_If_None_Match, 1, 0, 0, 0, 0)
-HTTPH("If-Range", H_If_Range, 1, 0, 0, 0, 0)
-HTTPH("If-Unmodified-Since", H_If_Unmodifed_Since, 1, 0, 0, 0, 0)
-HTTPH("Keep-Alive", H_Keep_Alive, 0, 0, 0, 0, 0)
-HTTPH("Max-Forwards", H_Max_Forwards, 1, 0, 0, 0, 0)
-HTTPH("Proxy-Authorization", H_Proxy_Authorization, 1, 0, 0, 0, 0)
-HTTPH("Range", H_Range, 1, 0, 0, 0, 0)
-HTTPH("Referer", H_Referer, 1, 0, 0, 0, 0)
-HTTPH("TE", H_TE, 1, 0, 0, 0, 0)
-HTTPH("User-Agent", H_User_Agent, 1, 0, 0, 0, 0)
+HTTPH("Connection", H_Connection, 3, 0, 0, 0, 0)
+HTTPH("Keep-Alive", H_Keep_Alive, 3, 0, 0, 0, 0)
+
+HTTPH("Accept-Charset", H_Accept_Charset, 1, 1, 0, 0, 0)
+HTTPH("Accept-Encoding", H_Accept_Encoding, 1, 1, 0, 0, 0)
+HTTPH("Accept-Language", H_Accept_Language, 1, 1, 0, 0, 0)
+HTTPH("Accept", H_Accept, 1, 1, 0, 0, 0)
+HTTPH("Authorization", H_Authorization, 1, 1, 0, 0, 0)
+HTTPH("Expect", H_Expect, 1, 1, 0, 0, 0)
+HTTPH("From", H_From, 1, 1, 0, 0, 0)
+HTTPH("Host", H_Host, 1, 1, 0, 0, 0)
+HTTPH("If-Match", H_If_Match, 1, 1, 0, 0, 0)
+HTTPH("If-Modified-Since", H_If_Modified_Since, 1, 1, 0, 0, 0)
+HTTPH("If-None-Match", H_If_None_Match, 1, 1, 0, 0, 0)
+HTTPH("If-Range", H_If_Range, 1, 1, 0, 0, 0)
+HTTPH("If-Unmodified-Since", H_If_Unmodifed_Since, 1, 1, 0, 0, 0)
+HTTPH("Max-Forwards", H_Max_Forwards, 1, 1, 0, 0, 0)
+HTTPH("Proxy-Authorization", H_Proxy_Authorization, 1, 1, 0, 0, 0)
+HTTPH("Range", H_Range, 1, 1, 0, 0, 0)
+HTTPH("Referer", H_Referer, 1, 1, 0, 0, 0)
+HTTPH("TE", H_TE, 1, 1, 0, 0, 0)
+HTTPH("User-Agent", H_User_Agent, 1, 1, 0, 0, 0)
+
+HTTPH("Server", H_Server, 2, 0, 0, 0, 0)
+HTTPH("Content-Type", H_Content_Type, 2, 0, 0, 0, 0)
+HTTPH("Date", H_Date, 2, 0, 0, 0, 0)
+HTTPH("Last-Modified", H_Last_Modified, 2, 0, 0, 0, 0)
+HTTPH("Accept-Ranges", H_Accept_Ranges, 2, 0, 0, 0, 0)
+HTTPH("Content-Length", H_Content_Length, 2, 0, 0, 0, 0)
+HTTPH("Cache-Control", H_Cache_Control, 2, 0, 0, 0, 0)
+HTTPH("Vary", H_Vary, 2, 0, 0, 0, 0)
+HTTPH("Expires", H_Expires, 2, 0, 0, 0, 0)
SLTM(SessionClose)
SLTM(ClientAddr)
SLTM(Request)
+SLTM(Response)
+SLTM(Status)
SLTM(URL)
SLTM(Protocol)
SLTM(HD_Unknown)
const char *req;
const char *url;
const char *proto;
+ const char *status;
+ const char *response;
#define HTTPH(a, b, c, d, e, f, g) const char *b;
#include <http_headers.h>
#undef HTTPH
fputs(" const char *req;\n", f);
fputs(" const char *url;\n", f);
fputs(" const char *proto;\n", f);
+ fputs(" const char *status;\n", f);
+ fputs(" const char *response;\n", f);
fputs("#define HTTPH(a, b, c, d, e, f, g) const char *b;\n", f);
fputs("/*\n", f);
fputs(" * $Id$\n", f);
fputs(" *\n", f);
fputs(" * a Http header name\n", f);
fputs(" * b session field name\n", f);
- fputs(" * c PassThrough handling (0=remove, 1=pass)\n", f);
- fputs(" * d unused\n", f);
+ fputs(" * c Request(1)/Response(2) bitfield\n", f);
+ fputs(" * d Pass header\n", f);
fputs(" * e unused\n", f);
fputs(" * f unused\n", f);
fputs(" * g unused\n", f);
fputs(" * a b c d e f g \n", f);
fputs(" *--------------------------------------------------------------------\n", f);
fputs(" */\n", f);
- fputs("HTTPH(\"Accept-Charset\", H_Accept_Charset, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Accept-Encoding\", H_Accept_Encoding, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Accept-Language\", H_Accept_Language, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Accept\", H_Accept, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Authorization\", H_Authorization, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Connection\", H_Connection, 0, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Expect\", H_Expect, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"From\", H_From, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Host\", H_Host, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"If-Match\", H_If_Match, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"If-Modified-Since\", H_If_Modified_Since, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"If-None-Match\", H_If_None_Match, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"If-Range\", H_If_Range, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"If-Unmodified-Since\", H_If_Unmodifed_Since, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Keep-Alive\", H_Keep_Alive, 0, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Max-Forwards\", H_Max_Forwards, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Proxy-Authorization\", H_Proxy_Authorization, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Range\", H_Range, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"Referer\", H_Referer, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"TE\", H_TE, 1, 0, 0, 0, 0)\n", f);
- fputs("HTTPH(\"User-Agent\", H_User_Agent, 1, 0, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Connection\", H_Connection, 3, 0, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Keep-Alive\", H_Keep_Alive, 3, 0, 0, 0, 0)\n", f);
+ fputs("\n", f);
+ fputs("HTTPH(\"Accept-Charset\", H_Accept_Charset, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Accept-Encoding\", H_Accept_Encoding, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Accept-Language\", H_Accept_Language, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Accept\", H_Accept, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Authorization\", H_Authorization, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Expect\", H_Expect, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"From\", H_From, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Host\", H_Host, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"If-Match\", H_If_Match, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"If-Modified-Since\", H_If_Modified_Since, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"If-None-Match\", H_If_None_Match, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"If-Range\", H_If_Range, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"If-Unmodified-Since\", H_If_Unmodifed_Since, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Max-Forwards\", H_Max_Forwards, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Proxy-Authorization\", H_Proxy_Authorization, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Range\", H_Range, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Referer\", H_Referer, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"TE\", H_TE, 1, 1, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"User-Agent\", H_User_Agent, 1, 1, 0, 0, 0)\n", f);
+ fputs("\n", f);
+ fputs("HTTPH(\"Server\", H_Server, 2, 0, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Content-Type\", H_Content_Type, 2, 0, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Date\", H_Date, 2, 0, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Last-Modified\", H_Last_Modified, 2, 0, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Accept-Ranges\", H_Accept_Ranges, 2, 0, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Content-Length\", H_Content_Length, 2, 0, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Cache-Control\", H_Cache_Control, 2, 0, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Vary\", H_Vary, 2, 0, 0, 0, 0)\n", f);
+ fputs("HTTPH(\"Expires\", H_Expires, 2, 0, 0, 0, 0)\n", f);
fputs("#undef HTTPH\n", f);
fputs(" const char *uhdr[VCA_UNKNOWNHDR];\n", f);
fputs(" unsigned nuhdr;\n", f);