]> git.ipfire.org Git - thirdparty/squid.git/blob - src/client_side_reply.h
Do not assert on native FTP ERR_TOO_BIG. Do not check for ERR_TOO_BIG twice.
[thirdparty/squid.git] / src / client_side_reply.h
1 /*
2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
4 *
5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 *
28 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
29 */
30
31 #ifndef SQUID_CLIENTSIDEREPLY_H
32 #define SQUID_CLIENTSIDEREPLY_H
33
34 #include "acl/forward.h"
35 #include "client_side_request.h"
36 #include "ip/forward.h"
37 #include "RequestFlags.h"
38 #include "StoreClient.h"
39
40 class ErrorState;
41
42 /* XXX make static method */
43
44 class clientReplyContext : public RefCountable, public StoreClient
45 {
46
47 public:
48 static STCB CacheHit;
49 static STCB HandleIMSReply;
50 static STCB SendMoreData;
51
52 clientReplyContext(ClientHttpRequest *);
53 ~clientReplyContext();
54
55 void saveState();
56 void restoreState();
57 void purgeRequest ();
58 void purgeRequestFindObjectToPurge();
59 void purgeDoMissPurge();
60 void purgeFoundGet(StoreEntry *newEntry);
61 void purgeFoundHead(StoreEntry *newEntry);
62 void purgeFoundObject(StoreEntry *entry);
63 void sendClientUpstreamResponse();
64 void purgeDoPurgeGet(StoreEntry *entry);
65 void purgeDoPurgeHead(StoreEntry *entry);
66 void doGetMoreData();
67 void identifyStoreObject();
68 void identifyFoundObject(StoreEntry *entry);
69 int storeOKTransferDone() const;
70 int storeNotOKTransferDone() const;
71 /// replaces current response store entry with the given one
72 void setReplyToStoreEntry(StoreEntry *e, const char *reason);
73 /// builds error using clientBuildError() and calls setReplyToError() below
74 void setReplyToError(err_type, Http::StatusCode, const HttpRequestMethod&, char const *, Ip::Address &, HttpRequest *, const char *,
75 #if USE_AUTH
76 Auth::UserRequest::Pointer);
77 #else
78 void * unused);
79 #endif
80 /// creates a store entry for the reply and appends err to it
81 void setReplyToError(const HttpRequestMethod& method, ErrorState *err);
82 /// creates a store entry for the reply and appends error reply to it
83 void setReplyToReply(HttpReply *reply);
84 void createStoreEntry(const HttpRequestMethod& m, RequestFlags flags);
85 void removeStoreReference(store_client ** scp, StoreEntry ** ep);
86 void removeClientStoreReference(store_client **scp, ClientHttpRequest *http);
87 void startError(ErrorState * err);
88 void processExpired();
89 clientStream_status_t replyStatus();
90 void processMiss();
91 void traceReply(clientStreamNode * node);
92 const char *storeId() const { return (http->store_id.size() > 0 ? http->store_id.termedBuf() : http->uri); }
93
94 Http::StatusCode purgeStatus;
95
96 /* state variable - replace with class to handle storeentries at some point */
97 int lookingforstore;
98 virtual void created (StoreEntry *newEntry);
99
100 ClientHttpRequest *http;
101 int headers_sz;
102 store_client *sc; /* The store_client we're using */
103 StoreIOBuffer tempBuffer; /* For use in validating requests via IMS */
104 int old_reqsize; /* ... again, for the buffer */
105 size_t reqsize;
106 size_t reqofs;
107 char tempbuf[HTTP_REQBUF_SZ]; /* a temporary buffer if we need working storage */
108 #if USE_CACHE_DIGESTS
109
110 const char *lookup_type; /* temporary hack: storeGet() result: HIT/MISS/NONE */
111 #endif
112
113 struct {
114
115 unsigned storelogiccomplete:1;
116
117 unsigned complete:1; /* we have read all we can from upstream */
118 bool headersSent;
119 } flags;
120 clientStreamNode *ourNode; /* This will go away if/when this file gets refactored some more */
121
122 private:
123 clientStreamNode *getNextNode() const;
124 void makeThisHead();
125 bool errorInStream(StoreIOBuffer const &result, size_t const &sizeToProcess)const ;
126 void sendStreamError(StoreIOBuffer const &result);
127 void pushStreamData(StoreIOBuffer const &result, char *source);
128 clientStreamNode * next() const;
129 StoreIOBuffer holdingBuffer;
130 HttpReply *reply;
131 void processReplyAccess();
132 static ACLCB ProcessReplyAccessResult;
133 void processReplyAccessResult(const allow_t &accessAllowed);
134 void cloneReply();
135 void buildReplyHeader ();
136 bool alwaysAllowResponse(Http::StatusCode sline) const;
137 int checkTransferDone();
138 void processOnlyIfCachedMiss();
139 void processConditional(StoreIOBuffer &result);
140 void cacheHit(StoreIOBuffer result);
141 void handleIMSReply(StoreIOBuffer result);
142 void sendMoreData(StoreIOBuffer result);
143 void triggerInitialStoreRead();
144 void sendClientOldEntry();
145 void purgeAllCached();
146 void forgetHit();
147 bool blockedHit() const;
148
149 void sendBodyTooLargeError();
150 void sendPreconditionFailedError();
151 void sendNotModified();
152 void sendNotModifiedOrPreconditionFailedError();
153
154 StoreEntry *old_entry;
155 store_client *old_sc; /* ... for entry to be validated */
156 bool deleting;
157
158 CBDATA_CLASS2(clientReplyContext);
159 };
160
161 #endif /* SQUID_CLIENTSIDEREPLY_H */