/*
- * $Id: client_side.cc,v 1.196 1998/01/09 01:18:12 wessels Exp $
+ * $Id: client_side.cc,v 1.197 1998/01/10 08:15:13 kostas Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
char *hdr_out,
size_t out_sz)
{
+ LOCAL_ARRAY(char, no_forward, 1024);
char *xbuf;
char *ybuf;
char *t = NULL;
end = mime_headers_end(hdr_in);
if (end == NULL) {
debug(12, 3) ("clientBuildReplyHeader: DIDN'T FIND END-OF-HEADERS\n");
- debug(12, 3) ("\n%s", hdr_in);
return 0;
}
xbuf = get_free_4k_page();
ybuf = get_free_4k_page();
+
for (t = hdr_in; t < end; t += strcspn(t, crlf), t += strspn(t, crlf)) {
hdr_len = t - hdr_in;
l = strcspn(t, crlf) + 1;
xstrncpy(xbuf, t, l > 4096 ? 4096 : l);
- debug(12, 5) ("clientBuildReplyHeader: %s\n", xbuf);
#if 0
if (strncasecmp(xbuf, "Accept-Ranges:", 14) == 0)
continue;
#endif
if (strncasecmp(xbuf, "Proxy-Connection:", 17) == 0)
continue;
- if (strncasecmp(xbuf, "Connection:", 11) == 0)
+ if (strncasecmp(xbuf, "Connection:", 11) == 0) {
+ handleConnectionHeader(0, no_forward, &xbuf[11]);
continue;
+ }
if (strncasecmp(xbuf, "Keep-Alive:", 11) == 0)
continue;
if (strncasecmp(xbuf, "Set-Cookie:", 11) == 0)
if (isTcpHit(http->log_type))
continue;
- clientAppendReplyHeader(hdr_out, xbuf, &len, out_sz - 512);
+ if (!handleConnectionHeader(1, no_forward, xbuf))
+ clientAppendReplyHeader(hdr_out, xbuf, &len, out_sz - 512);
}
hdr_len = end - hdr_in;
/* Append X-Cache: */
char C = '\0';
assert(size <= SM_PAGE_SIZE);
assert(http->request != NULL);
- debug(12, 5) ("clientSendMoreData: FD %d '%s', out.offset=%d\n",
+ debug(12, 5) ("clientSendMoreData: FD %d '%s', out.offset=%d \n",
fd, storeUrl(entry), http->out.offset);
if (conn->chr != http) {
/* there is another object in progress, defer this one */
*(buf + size) = '\0';
newbuf = get_free_8k_page();
hdrlen = 0;
+
l = clientBuildReplyHeader(http, buf, &hdrlen, newbuf, 8192);
if (hack)
*(buf + size++) = C;
fatal("Cannot open HTTP Port");
}
+int
+handleConnectionHeader(int flag, char *where, char *what)
+{
+ char *t, *p, *wh;
+ int i;
+ LOCAL_ARRAY(char, mbuf, 256);
+
+ if (flag) { /* lookup mode */
+ if (where[0] == '\0' || what[0] == '\0')
+ return 0;
+ p = xstrdup(what);
+ t = strtok(p, ":");
+ if (t == NULL)
+ return 0;
+ debug(20, 3) ("handleConnectionHeader: %s\n AND %s (%p)\n", where, t, p);
+ i = strstr(where, t) ? 1 : 0;
+ xfree(p);
+ return (i);
+ }
+ where[0] = '\0';
+ wh = xstrdup(what);
+ t = strtok(wh, ",");
+ while (t != NULL) {
+
+#ifdef BE_PARANOID
+ static char no_conn[] = "Expires:Host:Content-length:Content-type:";
+
+ if (handleConnectionHeader(1, no_conn, t)) {
+ debug(1, 1) ("handleConnectionHeader: problematic header %s\n", t);
+ t = strtok(NULL, ",\n");
+ continue;
+ }
+#endif
+ if ((p = strchr(t, ':')))
+ xstrncpy(mbuf, t, p - t + 1);
+ else
+ snprintf(mbuf, 256, "%s:", t);
+ strcat(where, mbuf);
+ t = strtok(NULL, ",\n");
+ }
+ debug(20, 3) ("handleConnectionHeader: we have %s\n", where);
+ xfree(wh);
+ return 1;
+}
+
void
clientHttpConnectionsClose(void)
{
/*
- * $Id: http.cc,v 1.231 1998/01/03 05:27:18 wessels Exp $
+ * $Id: http.cc,v 1.232 1998/01/10 08:15:14 kostas Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
int flags)
{
LOCAL_ARRAY(char, ybuf, YBUF_SZ);
+ LOCAL_ARRAY(char, no_forward, 1024);
char *xbuf = get_free_4k_page();
char *viabuf = get_free_4k_page();
char *fwdbuf = get_free_4k_page();
/* If we're not going to do proxy auth, then it must be passed on */
if (EBIT_TEST(request->flags, REQ_USED_PROXY_AUTH))
continue;
- if (strncasecmp(xbuf, "Connection:", 11) == 0)
+ if (strncasecmp(xbuf, "Connection:", 11) == 0) {
+ handleConnectionHeader(0, no_forward, &xbuf[11]);
continue;
+ }
if (strncasecmp(xbuf, "Host:", 5) == 0) {
EBIT_SET(hdr_flags, HDR_HOST);
} else if (strncasecmp(xbuf, "Cache-Control:", 14) == 0) {
snprintf(xbuf, 4096, "Max-Forwards: %d", n - 1);
}
}
- httpAppendRequestHeader(hdr_out, xbuf, &len, out_sz - 512, 1);
+ if (!handleConnectionHeader(1, no_forward, xbuf))
+ httpAppendRequestHeader(hdr_out, xbuf, &len, out_sz - 512, 1);
}
hdr_len = t - hdr_in;
if (Config.fake_ua && strstr(hdr_out, "User-Agent") == NULL) {