--------------------- PatchSet 2171 Date: 2001/05/01 00:02:41 Author: rbcollins Branch: newhttp Tag: (none) Log: converting request flow to filters Members: src/client_side.c:1.1.1.3.4.1.4.15.2.34->1.1.1.3.4.1.4.15.2.34.2.1 src/defines.h:1.1.1.3.8.7.2.8->1.1.1.3.8.7.2.8.2.1 src/filters.c:1.1.2.13->1.1.2.13.2.1 src/http.c:1.1.1.3.4.1.4.12.2.16->1.1.1.3.4.1.4.12.2.16.2.1 src/protos.h:1.1.1.3.8.11.2.20->1.1.1.3.8.11.2.20.2.1 src/structs.h:1.1.1.3.4.1.4.12.2.26->1.1.1.3.4.1.4.12.2.26.2.1 src/typedefs.h:1.1.1.3.8.7.4.24->1.1.1.3.8.7.4.24.2.1 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.1.1.3.4.1.4.15.2.34 retrieving revision 1.1.1.3.4.1.4.15.2.34.2.1 diff -u -r1.1.1.3.4.1.4.15.2.34 -r1.1.1.3.4.1.4.15.2.34.2.1 --- squid/src/client_side.c 27 Apr 2001 14:38:37 -0000 1.1.1.3.4.1.4.15.2.34 +++ squid/src/client_side.c 1 May 2001 00:02:41 -0000 1.1.1.3.4.1.4.15.2.34.2.1 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.1.1.3.4.1.4.15.2.34 2001/04/27 14:38:37 rbcollins Exp $ + * $Id: client_side.c,v 1.1.1.3.4.1.4.15.2.34.2.1 2001/05/01 00:02:41 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -88,7 +88,7 @@ static void clientProcessMiss(clientHttpRequest *); static void clientBuildReplyHeader(clientHttpRequest * http, HttpReply * rep); static clientHttpRequest *parseHttpRequestAbort(ConnStateData * conn, const char *uri); -static clientHttpRequest *parseHttpRequest(ConnStateData *, method_t *, int *, char **, size_t *); +static clientHttpRequest *parseHttpRequest(ConnStateData *, method_t *, int *, size_t *); static void clientRedirectStart(void *data); static RH clientRedirectDone; static void clientCheckNoCache(clientHttpRequest *); @@ -105,7 +105,7 @@ static void clientSetKeepaliveFlag(clientHttpRequest *); static void clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String boundary, MemBuf * mb); static void clientPackTermBound(String boundary, MemBuf * mb); -static void clientInterpretRequestHeaders(clientHttpRequest *); +static DATAFILTER_HDR clientInterpretRequestHeaders; static void clientProcessRequest(clientHttpRequest *); static void clientProcessExpired(void *data); static void clientProcessOnlyIfCachedMiss(clientHttpRequest * http); @@ -118,6 +118,11 @@ static int clientRequestBodyTooLarge(int clen); static void clientProcessBody(ConnStateData * conn); + +static DATAFILTER_HDR clientTemp; +static DATAFILTER_HDR clientHeadersLog; +static DATAFILTER_HDR clientfdnote; + static int checkAccelOnly(clientHttpRequest * http) { @@ -164,18 +169,40 @@ return ch; } -void -clientAccessCheck(void *data) +typedef struct _accessstate { + HttpReply *rep; + request_t *request; + dlink_list * filter_list; + FILTER_list * filters; + unsigned int flags; + void *data; +} accessstate; + +CBDATA_TYPE(accessstate); + +DATAFILTER_FILTERHEADER(clientAccessCheck) { clientHttpRequest *http = data; + accessstate *AccessState = NULL; + CBDATA_INIT_TYPE(accessstate); + AccessState = cbdataAlloc(accessstate); + AccessState->rep=rep; + AccessState->request=request; + AccessState->filter_list=filter_list; + AccessState->filters=filters; + AccessState->flags=flags; + AccessState->data=data; + cbdataLock(AccessState); if (checkAccelOnly(http)) { /* deny proxy requests in accel_only mode */ debug(33, 1) ("clientAccessCheck: proxy request denied in accel_only mode\n"); - clientAccessCheckDone(ACCESS_DENIED, http); - return; + clientAccessCheckDone(ACCESS_DENIED, AccessState); + return FILTER_ABORT; } + http->acl_checklist = clientAclChecklistCreate(Config.accessList.http, http); - aclNBCheck(http->acl_checklist, clientAccessCheckDone, http); + aclNBCheck(http->acl_checklist, clientAccessCheckDone, AccessState); + return 0; } /* @@ -214,11 +241,14 @@ void clientAccessCheckDone(int answer, void *data) { - clientHttpRequest *http = data; + accessstate *AccessState = data; + clientHttpRequest *http = AccessState->data; err_type page_id; http_status status; ErrorState *err = NULL; char *proxy_auth_msg = NULL; + FILTER_list *temp_filter; + temp_filter=AccessState->filters->node.next->data; debug(33, 2) ("The request %s %s is %s, because it matched '%s'\n", RequestMethodStr[http->request->method], http->uri, answer == ACCESS_ALLOWED ? "ALLOWED" : "DENIED", @@ -226,10 +256,15 @@ proxy_auth_msg = authenticateAuthUserRequestMessage(http->conn->auth_user_request ? http->conn->auth_user_request : http->request->auth_user_request); http->acl_checklist = NULL; if (answer == ACCESS_ALLOWED) { +/* WHY DO THIS? We just created http->uri before safe_free(http->uri); http->uri = xstrdup(urlCanonical(http->request)); - clientRedirectStart(http); +*/ +// clientRedirectStart(http); + temp_filter->filter_hdr(AccessState->rep, AccessState->request, AccessState->filter_list, temp_filter, AccessState->flags, temp_filter->data); } else { + /* FIXME: tell the filter chain we are aborting */ + debug(33, 5) ("Access Denied: %s\n", http->uri); debug(33, 5) ("AclMatchedName = %s\n", AclMatchedName ? AclMatchedName : ""); @@ -281,6 +316,8 @@ err->callback_data = NULL; errorAppendEntry(http->entry, err); } + dlinkDelete(&AccessState->filters->node, AccessState->filter_list); + xfree(AccessState->filters); } @@ -338,12 +375,13 @@ requestUnlink(old_request); http->request = requestLink(new_request); } - clientInterpretRequestHeaders(http); + /* FIXME: filter chain next call */ +/* clientInterpretRequestHeaders(http); #if HEADERS_LOG headersLog(0, 1, request->method, request); #endif fd_note(http->conn->fd, http->uri); - clientCheckNoCache(http); + clientCheckNoCache(http); */ } static void @@ -905,10 +943,13 @@ #endif } -static void -clientInterpretRequestHeaders(clientHttpRequest * http) + +DATAFILTER_FILTERHEADER (clientInterpretRequestHeaders) { - request_t *request = http->request; + FILTER_list *temp_filter=filters->node.next->data; + unsigned int rvflags; + clientHttpRequest * http=data; +// request_t *request = http->request; const HttpHeader *req_hdr = &request->header; int no_cache = 0; const char *str; @@ -1013,6 +1054,10 @@ request->flags.cachable ? "SET" : "NOT SET"); debug(33, 5) ("clientInterpretRequestHeaders: REQ_HIERARCHICAL = %s\n", request->flags.hierarchical ? "SET" : "NOT SET"); + rvflags = temp_filter->filter_hdr(rep,request,filter_list,temp_filter, flags, temp_filter->data); + dlinkDelete(&filters->node, filter_list); + xfree(filters); + return rvflags; } /* @@ -1331,7 +1376,7 @@ #endif -static DATAFILTER clientWriteReplyHeaders; +static DATAFILTER_HDR clientWriteReplyHeaders; static DATAFILTER clientDoCommWriteMemBuf; static DATAFILTER_HDR clientDoCommWriteHeaders; @@ -1930,7 +1975,7 @@ DATAFILTER clientDoCommWrite; -DATAFILTER_FILTER(clientWriteReplyHeaders) { +DATAFILTER_FILTERHEADER(clientWriteReplyHeaders) { clientHttpRequest *http = data; FILTER_list *temp_filter; unsigned int rvflags=0; @@ -1946,7 +1991,7 @@ */ debug (33,8)("clientWriteReplyHeaders: Beginning\n"); temp_filter=filters->node.next->data; - rvflags |= temp_filter->filter(buf,len, offset,filter_list, temp_filter, flags | FILTER_HTTP_HEADER, temp_filter->data); + rvflags |= temp_filter->filter_hdr(http->entry->mem_obj->reply,http->request,filter_list, temp_filter, flags | FILTER_HTTP_HEADER, temp_filter->data); dlinkDelete(&filters->node, filter_list); xfree(filters); http->flags.done_reply_headers=1; @@ -2059,7 +2104,9 @@ DATAFILTER_FILTERHEADER(clientDoCommWriteHeaders) { clientHttpRequest *http = data; MemBuf mb; - memBufDefInit(&mb); +// size_t len; + +// memBufDefInit(&mb); /* allocate a membuf, put the data from range and te into it, and call comm_write * membuf @@ -2075,33 +2122,25 @@ /* we are the last of the mohicans */ assert(filters->node.next==NULL); - assert((buf && len) || (flags & (FILTER_EOF | FILTER_ABORT))); - - debug (33,8)("clientDoCommWriteHeaders: buf %p len %d flags %d\n",buf,len,flags); - if (!buf || !len) { - /* No new data to write */ - /* if not EOF, then some error occured upstream... abort here TODO */ - clientWriteComplete(http->conn->fd, NULL, 0, 0, http); - /* TODO: when we start buffer blocks here, this is where we flush the buffer */ - /* Why? calling clientWriteComplete flushes the buffer too */ - return 0; - } + debug (33,8)("clientDoCommWriteHeaders: reply %p flags %d\n",rep,flags); /* there is data to write. Concept: buffer 4K/client sock buf/ whatever here * and only call TCP/IP layer when EOF or a larger amount is present ??? */ + mb = httpReplyPack(rep); + if (flags & FILTER_EOF) http->flags.done_copying=1; if (!http->flags.reply_write_in_progress) { http->flags.reply_write_in_progress=1; - memBufAppend(&mb, buf, len); + /* FIXME: just call commWrite */ comm_write_mbuf(http->conn->fd, mb, clientWriteComplete, http); - } else { + } else { /* FIXME: just call commWrite */ /* queue the data to the http membuffer */ - if (!http->mb.buf) - memBufDefInit(&http->mb); - memBufAppend(&http->mb, buf, len); +// if (!http->mb.buf) + // memBufDefInit(&http->mb); + // memBufAppend(&http->mb, buf, len); } // comm_write(http->conn->fd, buf, len, clientWriteBodyComplete, http, NULL); return 0; @@ -2924,7 +2963,7 @@ */ static clientHttpRequest * parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status, - char **prefix_p, size_t * req_line_sz_p) + size_t * req_line_sz_p) { char *inbuf = NULL; char *mstr = NULL; @@ -2933,6 +2972,8 @@ http_version_t http_ver; char *token = NULL; char *t = NULL; + char *lprefix; + char **prefix_p=&lprefix; char *end; size_t header_sz; /* size of headers, not including first line */ size_t prefix_sz; /* size of whole request (req-line + headers) */ @@ -2940,6 +2981,8 @@ size_t req_sz; method_t method; clientHttpRequest *http = NULL; + HttpHeader hdr; + request_t *request = NULL; #if IPF_TRANSPARENT struct natlookup natLookup; static int natfd = -1; @@ -2960,6 +3003,7 @@ assert(req_sz <= conn->in.offset); /* Use memcpy, not strdup! */ inbuf = xmalloc(req_sz + 1); +/* FIXME: wecopy here because we alter the data! */ xmemcpy(inbuf, conn->in.buf, req_sz); *(inbuf + req_sz) = '\0'; @@ -3026,12 +3070,32 @@ */ req_hdr = strtok(NULL, null_string); header_sz = req_sz - (req_hdr - inbuf); + + httpHeaderInit(&hdr, hoRequest); + /* httpRequestParseHeader uses MsgIsolateHeaders ..*/ + if (!httpHeaderParse(&hdr, req_hdr, req_hdr + header_sz)) { + debug(33, 3) ("parseHttpRequest: couldn't parse header\n"); + return NULL; + } + +/* Dump the headers */ +{ + HttpHeaderPos pos = HttpHeaderInitPos; + const HttpHeaderEntry *e; + debug(55, 7) ("packing hdr: (%p)\n", &hdr); + /* pack all entries one by one */ + while ((e = httpHeaderGetEntry(&hdr, &pos))) +printf("%s: %s\r\n",strBuf(e->name),strBuf(e->value)); +} + + if (0 == header_sz) { debug(33, 3) ("parseHttpRequest: header_sz == 0\n"); *status = 0; return NULL; } assert(header_sz > 0); + debug(33, 3) ("parseHttpRequest: req_hdr = {%s}\n", req_hdr); end = req_hdr + header_sz; debug(33, 3) ("parseHttpRequest: end = {%s}\n", end); @@ -3054,7 +3118,7 @@ *(*prefix_p + prefix_sz) = '\0'; dlinkAdd(http, &http->active, &ClientActiveRequests); - debug(33, 5) ("parseHttpRequest: Request Header is\n%s\n", (*prefix_p) + *req_line_sz_p); +// debug(33, 5) ("parseHttpRequest: Request Header is\n%s\n", (*prefix_p) + *req_line_sz_p); if ((t = strchr(url, '#'))) /* remove HTML anchors */ *t = '\0'; @@ -3068,10 +3132,12 @@ /* see if we running in Config2.Accel.on, if so got to convert it to URL */ else if (Config2.Accel.on && *url == '/') { /* prepend the accel prefix */ - if (opt_accel_uses_host && (t = mime_get_header(req_hdr, "Host"))) { +// if (opt_accel_uses_host && (t = mime_get_header(req_hdr, "Host"))) { + if (opt_accel_uses_host && (httpHeaderHas(&hdr, HDR_HOST))) { int vport; char *q; char *protocol_name = "http"; + String host = httpHeaderGetStrOrList(&hdr, HDR_HOST); if (vport_mode) vport = (int) ntohs(http->conn->me.sin_port); else @@ -3085,6 +3151,9 @@ * refer to www.playboy.com. The 'dst' and/or 'dst_domain' ACL * types should be used to prevent httpd-accelerators * handling requests for non-local servers */ + +/* FIXME: use string tools on the header host */ + t = xstrdup (strBuf(host)); strtok(t, " /;@"); if ((q = strchr(t, ':'))) { *q++ = '\0'; @@ -3103,6 +3172,7 @@ #endif snprintf(http->uri, url_sz, "%s://%s:%d%s", protocol_name, t, vport, url); + safe_free(t); } else if (vhost_mode) { int vport; /* Put the local socket IP address as the hostname */ @@ -3188,10 +3258,110 @@ http->log_uri = xstrndup(rfc1738_escape_unescaped(http->uri), MAX_URL); debug(33, 5) ("parseHttpRequest: Complete request received\n"); xfree(inbuf); - *status = 1; + /* Now we know the correct URI */ + if ((request = urlParse(method, http->uri)) == NULL) { + fatal("failed to parse uri after succesful early parse\n"); + } + request->flags.accelerated = http->flags.accel; + request->header=hdr; + if (!http->flags.internal) { + if (internalCheck(strBuf(request->urlpath))) { + if (internalHostnameIs(request->host) && + request->port == ntohs(Config.Sockaddr.http->s.sin_port)) { + http->flags.internal = 1; + } else if (internalStaticCheck(strBuf(request->urlpath))) { + xstrncpy(request->host, internalHostname(), SQUIDHOSTNAMELEN); + request->port = ntohs(Config.Sockaddr.http->s.sin_port); + http->flags.internal = 1; + } + } + } + + /* cache some common data */ + request->content_length = httpHeaderGetInt(&request->header, + HDR_CONTENT_LENGTH); + request->flags.internal = http->flags.internal; + + /* FIXME: how many times do we do this? */ + safe_free(http->log_uri); + http->log_uri = xstrdup(urlCanonicalClean(request)); + /* fill in some more request state data. */ + request->client_addr = conn->peer.sin_addr; + request->my_addr = conn->me.sin_addr; + request->my_port = ntohs(conn->me.sin_port); + request->http_ver = http->http_ver; + /* FIXME: broker function */ + + if (!urlCheckRequest(request)) { + *status = -1; + return parseHttpRequestAbort(conn, "error: non support method"); + } + + /* this is protocol specific. It's good. */ + if (!clientCheckContentLength(request)) { + *status = -2; + return parseHttpRequestAbort(conn, "error: non support method"); + } + + http->request = requestLink(request); + /* FIXME: we're doing this way early... or are we? */ + clientSetKeepaliveFlag(http); + + /* Do we expect a request-body? */ + /* we might receive reqest-bodies encoded with transfer-encoding. + * RFC 2616 is vague on this. For now, we detect it and log it to cache.log */ + if (httpHeaderHas(&http->request->header, HDR_TRANSFER_ENCODING)) + debug(33,0)("client_side has recieved a transfer encoded request entity -we cannot handle this yet. REPORT THIS to Squid-dev@squid-cache.org\n"); + + /* FIXME: we've got potential state variable headaches */ +// filterChainAddTail(&http->reqfilters, identity_body, clientAccessCheck, NULL,http); + filterChainAddTail(&http->reqfilters, identity_body,clientInterpretRequestHeaders, NULL,http); +#if HEADERS_LOG + filterChainAddTail(&http->reqfilters, identity_body, clientHeadersLog, NULL,http); +#endif + filterChainAddTail(&http->reqfilters, identity_body, clientfdnote, NULL,http); + filterChainAddTail(&http->reqfilters, identity_body, clientTemp, NULL,http); +// filterChainAddTail(&http->reqfilters, identity_body, clientTemp, NULL,http); + + + + *status = 1; /* success */ + return http; } +DATAFILTER_FILTERHEADER(clientHeadersLog) { + FILTER_list *temp_filter=filters->node.next->data; + clientHttpRequest *http=data; + unsigned int rvflags; +#if HEADERS_LOG + headersLog(0, 1, http->request->method, http->request); +#endif + rvflags = temp_filter->filter_hdr(rep,request,filter_list,temp_filter, flags, temp_filter->data); + dlinkDelete(&filters->node, filter_list); + xfree(filters); + return rvflags; +} + +DATAFILTER_FILTERHEADER(clientfdnote) { + FILTER_list *temp_filter=filters->node.next->data; + unsigned int rvflags; + clientHttpRequest *http=data; + fd_note(http->conn->fd, http->uri); + rvflags = temp_filter->filter_hdr(rep,request,filter_list,temp_filter, flags, temp_filter->data); + dlinkDelete(&filters->node, filter_list); + xfree(filters); + return rvflags; +} + +DATAFILTER_FILTERHEADER(clientTemp) { + FILTER_list *temp_filter=filters->node.next->data; + unsigned int rvflags; + clientHttpRequest *http=data; + clientCheckNoCache(http); + return 0; +} + static int clientReadDefer(int fdnotused, void *data) { @@ -3208,17 +3378,19 @@ ConnStateData *conn = data; int parser_return_code = 0; int k; - request_t *request = NULL; +// request_t *request = NULL; int size; void *p; method_t method; clientHttpRequest *http = NULL; clientHttpRequest **H = NULL; - char *prefix = NULL; ErrorState *err = NULL; fde *F = &fd_table[fd]; int len = conn->in.size - conn->in.offset - 1; debug(33, 4) ("clientReadRequest: FD %d: reading request...\n", fd); + /* FIXME: this bit is for adrian. I don't know what the modio/event network stuff + * can do or is capable of + */ statCounter.syscalls.sock.reads++; size = FD_READ_METHOD(fd, conn->in.buf + conn->in.offset, len); if (size > 0) { @@ -3269,15 +3441,30 @@ } /* Continue to process previously read data */ } + + /* DON'T DO THIS FIXME */ + commSetSelect(fd, COMM_SELECT_READ, clientReadRequest, conn, 0); + + + /* FIXME this is the first thing to change. We need to change the select to call + * our initiating filter when a request is being read + */ + /* Process request body if any */ if (conn->in.offset > 0 && conn->body.callback != NULL) + // { temp_filter = http->reqfilters.head; rvflags = temp_filter->filter_hdr(NULL, http->request, &http->reqfilters, temp_filter, 0, temp_filter->data); } clientProcessBody(conn); + + + + /* Process next request */ while (conn->in.offset > 0 && conn->body.size_left == 0) { int nrequests; size_t req_line_sz; /* Skip leading (and trailing) whitespace */ + /* FIXME: this buffer fiddle is bad bad bad */ while (conn->in.offset > 0 && xisspace(conn->in.buf[0])) { xmemmove(conn->in.buf, conn->in.buf + 1, conn->in.offset - 1); conn->in.offset--; @@ -3296,15 +3483,22 @@ conn->in.buf[conn->in.offset] = '\0'; /* Terminate the string */ if (nrequests == 0) fd_note(conn->fd, "Reading next request"); + + + + /* Process request */ http = parseHttpRequest(conn, &method, &parser_return_code, - &prefix, &req_line_sz); - if (!http) - safe_free(prefix); + + +// we have a parsed request, with headers in + if (http) { + FILTER_list *temp_filter; + unsigned int rvflags; assert(http->req_sz > 0); conn->in.offset -= http->req_sz; assert(conn->in.offset >= 0); @@ -3328,98 +3522,30 @@ */ commSetTimeout(fd, Config.Timeout.lifetime, clientLifetimeTimeout, http); if (parser_return_code < 0) { + //FIXME: case of return values */ debug(33, 1) ("clientReadRequest: FD %d Invalid Request\n", fd); err = errorCon(ERR_INVALID_REQ, HTTP_BAD_REQUEST); err->request_hdrs = xstrdup(conn->in.buf); http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); - safe_free(prefix); break; } - if ((request = urlParse(method, http->uri)) == NULL) { - debug(33, 5) ("Invalid URL: %s\n", http->uri); - err = errorCon(ERR_INVALID_URL, HTTP_BAD_REQUEST); - err->src_addr = conn->peer.sin_addr; - err->url = xstrdup(http->uri); - http->al.http.code = err->http_status; - http->entry = clientCreateStoreEntry(http, method, null_request_flags); - errorAppendEntry(http->entry, err); - safe_free(prefix); - break; - } else { - /* compile headers */ - /* we should skip request line! */ - if (!httpRequestParseHeader(request, prefix + req_line_sz)) - debug(33, 1) ("Failed to parse request headers: %s\n%s\n", - http->uri, prefix); - /* continue anyway? */ - } - request->flags.accelerated = http->flags.accel; - if (!http->flags.internal) { - if (internalCheck(strBuf(request->urlpath))) { - if (internalHostnameIs(request->host) && - request->port == ntohs(Config.Sockaddr.http->s.sin_port)) { - http->flags.internal = 1; - } else if (internalStaticCheck(strBuf(request->urlpath))) { - xstrncpy(request->host, internalHostname(), SQUIDHOSTNAMELEN); - request->port = ntohs(Config.Sockaddr.http->s.sin_port); - http->flags.internal = 1; - } - } - } - /* - * cache the Content-length value in request_t. - */ - request->content_length = httpHeaderGetInt(&request->header, - HDR_CONTENT_LENGTH); - request->flags.internal = http->flags.internal; - safe_free(prefix); - safe_free(http->log_uri); - http->log_uri = xstrdup(urlCanonicalClean(request)); - request->client_addr = conn->peer.sin_addr; - request->my_addr = conn->me.sin_addr; - request->my_port = ntohs(conn->me.sin_port); - request->http_ver = http->http_ver; - if (!urlCheckRequest(request)) { - err = errorCon(ERR_UNSUP_REQ, HTTP_NOT_IMPLEMENTED); - err->src_addr = conn->peer.sin_addr; - err->request = requestLink(request); - request->flags.proxy_keepalive = 0; - http->al.http.code = err->http_status; - http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); - errorAppendEntry(http->entry, err); - break; - } - if (!clientCheckContentLength(request)) { - err = errorCon(ERR_INVALID_REQ, HTTP_LENGTH_REQUIRED); - err->src_addr = conn->peer.sin_addr; - err->request = requestLink(request); - http->al.http.code = err->http_status; - http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); - errorAppendEntry(http->entry, err); - break; - } - http->request = requestLink(request); - clientSetKeepaliveFlag(http); - /* Do we expect a request-body? */ - /* we might receive reqest-bodies encoded with transfer-encoding. - * RFC 2616 is vague on this. For now, we detect it and log it to cache.log */ - if (httpHeaderHas(&http->request->header, HDR_TRANSFER_ENCODING)) - debug(33,0)("client_side has recieved a transfer encoded request entity - we cannot handle this yet. REPORT THIS to Squid-dev@squid-cache.org\n"); - if (request->content_length > 0) { - conn->body.size_left = request->content_length; - request->body_connection = conn; - /* Is it too large? */ - if (clientRequestBodyTooLarge(request->content_length)) { - err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE); - err->request = requestLink(request); - http->entry = clientCreateStoreEntry(http, - METHOD_NONE, null_request_flags); - errorAppendEntry(http->entry, err); - break; - } - } - clientAccessCheck(http); + /* Do we expect a request-body? */ + if (http->request->content_length > 0) { + conn->body.size_left = http->request->content_length; + http->request->body_connection = conn; + /* Is it too large? */ + if (clientRequestBodyTooLarge(http->request->content_length)) { + err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE); + err->request = requestLink(http->request); + http->entry = clientCreateStoreEntry(http, + METHOD_NONE, null_request_flags); + errorAppendEntry(http->entry, err); + break; + } + } + temp_filter = http->reqfilters.head->data; + rvflags = temp_filter->filter_hdr(NULL, http->request, &http->reqfilters, temp_filter, 0, temp_filter->data); continue; /* while offset > 0 && body.size_left == 0 */ } else if (parser_return_code == 0) { /* @@ -3465,6 +3591,7 @@ if (conn->in.offset != conn->body.size_left) { /* != 0 when no request body */ /* Partial request received. Abort client connection! */ debug(33, 3) ("clientReadRequest: FD %d aborted\n", fd); + // temp_filter = http->reqfilters.head; rvflags = temp_filter->filter_hdr(NULL, http->request, &http->reqfilters, temp_filter, FILTER_ABORT, temp_filter->data); comm_close(fd); return; } Index: squid/src/defines.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/defines.h,v retrieving revision 1.1.1.3.8.7.2.8 retrieving revision 1.1.1.3.8.7.2.8.2.1 diff -u -r1.1.1.3.8.7.2.8 -r1.1.1.3.8.7.2.8.2.1 --- squid/src/defines.h 27 Apr 2001 14:38:38 -0000 1.1.1.3.8.7.2.8 +++ squid/src/defines.h 1 May 2001 00:02:41 -0000 1.1.1.3.8.7.2.8.2.1 @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.1.1.3.8.7.2.8 2001/04/27 14:38:38 rbcollins Exp $ + * $Id: defines.h,v 1.1.1.3.8.7.2.8.2.1 2001/05/01 00:02:41 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -336,7 +336,7 @@ /* Prototypes for lazy coding */ #define DATAFILTER_FILTER(func_name) static unsigned int func_name(const char *buf, size_t len, size_t offset, dlink_list * filter_list,FILTER_list * filters, unsigned int flags, void *data) -#define DATAFILTER_FILTERHEADER(func_name) static unsigned int func_name(const char *buf, size_t len, size_t offset, dlink_list * filter_list,FILTER_list * filters, unsigned int flags, void *data) +#define DATAFILTER_FILTERHEADER(func_name) static unsigned int func_name(HttpReply *rep, request_t *request, dlink_list * filter_list,FILTER_list * filters, unsigned int flags, void *data) #endif Index: squid/src/filters.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/filters.c,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.13.2.1 diff -u -r1.1.2.13 -r1.1.2.13.2.1 --- squid/src/filters.c 28 Apr 2001 13:05:19 -0000 1.1.2.13 +++ squid/src/filters.c 1 May 2001 00:02:41 -0000 1.1.2.13.2.1 @@ -1,6 +1,6 @@ /* - * $Id: filters.c,v 1.1.2.13 2001/04/28 13:05:19 adri Exp $ + * $Id: filters.c,v 1.1.2.13.2.1 2001/05/01 00:02:41 rbcollins Exp $ * * DEBUG: section 83 Content Processing Filters * AUTHOR: Robert Collins @@ -275,7 +275,7 @@ * identity filter function: does nothing with the headers */ unsigned int -identity_header(const char *buf,size_t len, size_t offset, +identity_header(HttpReply *rep, request_t *request, dlink_list * filter_list,FILTER_list * filters, unsigned int flags, void *data) { @@ -283,7 +283,7 @@ temp_filter = filters->node.next->data; debug (83, 8) ("identity_header: skipping headers\n"); - return temp_filter->filter_hdr(buf, len, offset, filter_list, + return temp_filter->filter_hdr(rep, request, filter_list, temp_filter, flags, temp_filter->data); } @@ -303,7 +303,7 @@ temp_filter=filters->node.next->data; debug (83, 8) ("identity_header: skipping headers\n"); - return temp_filter->filter_hdr(buf, len, offset, filter_list, + return temp_filter->filter(buf, len, offset, filter_list, temp_filter, flags, temp_filter->data); } Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.1.1.3.4.1.4.12.2.16 retrieving revision 1.1.1.3.4.1.4.12.2.16.2.1 diff -u -r1.1.1.3.4.1.4.12.2.16 -r1.1.1.3.4.1.4.12.2.16.2.1 --- squid/src/http.c 27 Apr 2001 14:39:04 -0000 1.1.1.3.4.1.4.12.2.16 +++ squid/src/http.c 1 May 2001 00:02:41 -0000 1.1.1.3.4.1.4.12.2.16.2.1 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.1.1.3.4.1.4.12.2.16 2001/04/27 14:39:04 rbcollins Exp $ + * $Id: http.c,v 1.1.1.3.4.1.4.12.2.16.2.1 2001/05/01 00:02:41 rbcollins Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -556,7 +556,7 @@ unsigned int httpProcessData(const char *buf, size_t len, void *data); static DATAFILTER httpDoAppend; -static DATAFILTER httpDoAppendHeaders; +static DATAFILTER_HDR httpDoAppendHeaders; /* This will be called when data is ready to be read from fd. Read until * error or connection closed. */ @@ -758,7 +758,10 @@ /* Send the data to the store manager */ - filterChainAddTail(&httpState->filters,httpDoAppend,httpDoAppendHeaders, NULL,httpState); + filterChainAddTail(&httpState->filters,httpDoAppend,identity_header, NULL, httpState); + + /* process the headers */ +// filterChainAddTail(&httpState->filters,httpDoAppendHeaders, identity_header, NULL,httpState); #if WIP_FWD_LOG fwdStatus(httpState->fwd, s); #endif @@ -901,6 +904,7 @@ * as needed. */ DATAFILTER_FILTERHEADER(httpDoAppendHeaders) { +#if 0 HttpStateData *httpState = data; StoreEntry *entry = httpState->entry; const request_t *request = httpState->request; @@ -923,6 +927,7 @@ rvflags |= FILTER_ABORT; } return rvflags; +#endif } /* This will be called when request write is complete. Schedule read of Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.1.1.3.8.11.2.20 retrieving revision 1.1.1.3.8.11.2.20.2.1 diff -u -r1.1.1.3.8.11.2.20 -r1.1.1.3.8.11.2.20.2.1 --- squid/src/protos.h 27 Apr 2001 14:39:05 -0000 1.1.1.3.8.11.2.20 +++ squid/src/protos.h 1 May 2001 00:02:41 -0000 1.1.1.3.8.11.2.20.2.1 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.1.1.3.8.11.2.20 2001/04/27 14:39:05 rbcollins Exp $ + * $Id: protos.h,v 1.1.1.3.8.11.2.20.2.1 2001/05/01 00:02:41 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -122,7 +122,6 @@ extern void clientdbFreeMemory(void); extern int clientdbEstablished(struct in_addr, int); -extern void clientAccessCheck(void *); extern void clientAccessCheckDone(int, void *); extern int modifiedSince(StoreEntry *, request_t *); extern char *clientConstructTraceEcho(clientHttpRequest *); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.1.1.3.4.1.4.12.2.26 retrieving revision 1.1.1.3.4.1.4.12.2.26.2.1 diff -u -r1.1.1.3.4.1.4.12.2.26 -r1.1.1.3.4.1.4.12.2.26.2.1 --- squid/src/structs.h 27 Apr 2001 14:53:51 -0000 1.1.1.3.4.1.4.12.2.26 +++ squid/src/structs.h 1 May 2001 00:02:41 -0000 1.1.1.3.4.1.4.12.2.26.2.1 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.1.1.3.4.1.4.12.2.26 2001/04/27 14:53:51 rbcollins Exp $ + * $Id: structs.h,v 1.1.1.3.4.1.4.12.2.26.2.1 2001/05/01 00:02:41 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -266,7 +266,7 @@ struct _FILTER_list { dlink_node node; DATAFILTER * filter; - DATAFILTER * filter_hdr; + DATAFILTER_HDR * filter_hdr; REMOVEFILTER *Remove; void *data; }; Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.1.1.3.8.7.4.24 retrieving revision 1.1.1.3.8.7.4.24.2.1 diff -u -r1.1.1.3.8.7.4.24 -r1.1.1.3.8.7.4.24.2.1 --- squid/src/typedefs.h 27 Apr 2001 14:39:05 -0000 1.1.1.3.8.7.4.24 +++ squid/src/typedefs.h 1 May 2001 00:02:41 -0000 1.1.1.3.8.7.4.24.2.1 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.1.1.3.8.7.4.24 2001/04/27 14:39:05 rbcollins Exp $ + * $Id: typedefs.h,v 1.1.1.3.8.7.4.24.2.1 2001/05/01 00:02:41 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -375,7 +375,8 @@ * FLAGS */ typedef unsigned int DATAFILTER(const char *, size_t ,size_t, dlink_list *, FILTER_list *, unsigned int, void *); -typedef unsigned int DATAFILTER_HDR(const char *, size_t ,size_t, dlink_list *, FILTER_list *, unsigned int, void *); +/* request struct, filter list pointers, flags, state data */ +typedef unsigned int DATAFILTER_HDR(HttpReply *, request_t *, dlink_list *, FILTER_list *, unsigned int, void *); /* self, the list, the state */ typedef void REMOVEFILTER(FILTER_list *, dlink_list *, void*); typedef void *FILTERMKSTATE(void *, clientHttpRequest *, HttpReply *, request_t *);