1 Index: squid/src/HttpReply.c
2 diff -c squid/src/HttpReply.c:1.49 squid/src/HttpReply.c:1.49.2.1
3 *** squid/src/HttpReply.c:1.49 Wed Oct 24 02:19:08 2001
4 --- squid/src/HttpReply.c Tue May 6 14:13:02 2003
10 - rep->maxBodySize = 0;
11 rep->pstate = psReadyToParseStartLine;
12 httpBodyInit(&rep->body);
13 httpHeaderInit(&rep->header, hoReply);
17 else if (reply->sline.status < HTTP_OK)
19 return reply->content_length;
23 - * Calculates the maximum size allowed for an HTTP response
26 - httpReplyBodyBuildSize(request_t * request, HttpReply * reply, dlink_list * bodylist)
29 - aclCheck_t *checklist;
30 - bs = (body_size *) bodylist->head;
32 - checklist = aclChecklistCreate(bs->access_list, request, NULL);
33 - checklist->reply = reply;
34 - if (1 != aclCheckFast(bs->access_list, checklist)) {
35 - /* deny - skip this entry */
36 - bs = (body_size *) bs->node.next;
38 - /* Allow - use this entry */
39 - reply->maxBodySize = bs->maxsize;
41 - debug(58, 3) ("httpReplyBodyBuildSize: Setting maxBodySize to %ld\n", (long int) reply->maxBodySize);
43 - aclChecklistFree(checklist);
47 Index: squid/src/client_side.c
48 diff -c squid/src/client_side.c:1.561.2.33 squid/src/client_side.c:1.561.2.34
49 *** squid/src/client_side.c:1.561.2.33 Wed Feb 19 16:39:12 2003
50 --- squid/src/client_side.c Tue May 6 14:13:02 2003
53 static int clientCheckContentLength(request_t * r);
54 static DEFER httpAcceptDefer;
55 static log_type clientProcessRequest2(clientHttpRequest * http);
56 ! static int clientReplyBodyTooLarge(HttpReply *, ssize_t clen);
57 static int clientRequestBodyTooLarge(int clen);
58 static void clientProcessBody(ConnStateData * conn);
61 static int clientCheckContentLength(request_t * r);
62 static DEFER httpAcceptDefer;
63 static log_type clientProcessRequest2(clientHttpRequest * http);
64 ! static int clientReplyBodyTooLarge(clientHttpRequest *, ssize_t clen);
65 static int clientRequestBodyTooLarge(int clen);
66 static void clientProcessBody(ConnStateData * conn);
70 return i->debt_size > 0;
74 ! clientReplyBodyTooLarge(HttpReply * rep, ssize_t clen)
76 ! if (0 == rep->maxBodySize)
77 return 0; /* disabled */
79 return 0; /* unknown */
80 ! if (clen > rep->maxBodySize)
81 return 1; /* too large */
85 return i->debt_size > 0;
89 + * Calculates the maximum size allowed for an HTTP response
92 + clientMaxBodySize(request_t * request, clientHttpRequest * http, HttpReply * reply)
95 + aclCheck_t *checklist;
96 + bs = (body_size *) Config.ReplyBodySize.head;
98 + checklist = clientAclChecklistCreate(bs->access_list, http);
99 + checklist->reply = reply;
100 + if (1 != aclCheckFast(bs->access_list, checklist)) {
101 + /* deny - skip this entry */
102 + bs = (body_size *) bs->node.next;
104 + /* Allow - use this entry */
105 + http->maxBodySize = bs->maxsize;
107 + debug(58, 3) ("httpReplyBodyBuildSize: Setting maxBodySize to %ld\n", (long int) http->maxBodySize);
109 + aclChecklistFree(checklist);
114 ! clientReplyBodyTooLarge(clientHttpRequest * http, ssize_t clen)
116 ! if (0 == http->maxBodySize)
117 return 0; /* disabled */
119 return 0; /* unknown */
120 ! if (clen > http->maxBodySize)
121 return 1; /* too large */
131 * accepts chunk of a http message in buf, parses prefix, filters headers and
132 * such, writes processed message to the client's socket
139 ! httpReplyBodyBuildSize(http->request, rep, &Config.ReplyBodySize);
140 ! if (clientReplyBodyTooLarge(rep, rep->content_length)) {
141 ErrorState *err = errorCon(ERR_TOO_BIG, HTTP_FORBIDDEN);
142 err->request = requestLink(http->request);
143 storeUnregister(http->sc, http->entry, http);
148 ! clientMaxBodySize(http->request, http, rep);
149 ! if (clientReplyBodyTooLarge(http, rep->content_length)) {
150 ErrorState *err = errorCon(ERR_TOO_BIG, HTTP_FORBIDDEN);
151 err->request = requestLink(http->request);
152 storeUnregister(http->sc, http->entry, http);
158 ! } else if (clientReplyBodyTooLarge(entry->mem_obj->reply, http->out.offset)) {
161 /* More data will be coming from primary server; register with
166 ! } else if (clientReplyBodyTooLarge(http, http->out.offset - 4096)) {
167 ! /* 4096 is a margin for the HTTP headers included in out.offset */
170 /* More data will be coming from primary server; register with
171 Index: squid/src/protos.h
172 diff -c squid/src/protos.h:1.420.2.17 squid/src/protos.h:1.420.2.18
173 *** squid/src/protos.h:1.420.2.17 Thu Jan 2 16:10:46 2003
174 --- squid/src/protos.h Tue May 6 14:13:02 2003
177 extern int httpReplyHasCc(const HttpReply * rep, http_hdr_cc_type type);
178 extern void httpRedirectReply(HttpReply *, http_status, const char *);
179 extern int httpReplyBodySize(method_t, HttpReply *);
180 - extern void httpReplyBodyBuildSize(request_t *, HttpReply *, dlink_list *);
183 extern request_t *requestCreate(method_t, protocol_t, const char *urlpath);
185 Index: squid/src/structs.h
186 diff -c squid/src/structs.h:1.408.2.9 squid/src/structs.h:1.408.2.10
187 *** squid/src/structs.h:1.408.2.9 Mon Jan 20 17:06:39 2003
188 --- squid/src/structs.h Tue May 6 14:13:03 2003
191 HttpStatusLine sline;
193 HttpBody body; /* for small constant memory-resident text bodies only */
194 - size_t maxBodySize;
197 struct _http_state_flags {
205 + size_t maxBodySize;
208 struct _ConnStateData {