2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
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.
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.
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.
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.
28 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
31 #ifndef SQUID_CLIENTSIDEREPLY_H
32 #define SQUID_CLIENTSIDEREPLY_H
35 #include "HttpHeader.h"
36 #include "clientStream.h"
37 #include "StoreClient.h"
38 #include "client_side_request.h"
41 #include "ip/forward.h"
43 /* XXX make static method */
45 class clientReplyContext
: public RefCountable
, public StoreClient
49 void *operator new (size_t byteCount
);
50 void operator delete (void *address
);
52 static STCB HandleIMSReply
;
53 static STCB SendMoreData
;
55 clientReplyContext(ClientHttpRequest
*);
56 ~clientReplyContext();
61 void purgeRequestFindObjectToPurge();
62 void purgeDoMissPurge();
63 void purgeFoundGet(StoreEntry
*newEntry
);
64 void purgeFoundHead(StoreEntry
*newEntry
);
65 void purgeFoundObject(StoreEntry
*entry
);
66 void sendClientUpstreamResponse();
67 void purgeDoPurgeGet(StoreEntry
*entry
);
68 void purgeDoPurgeHead(StoreEntry
*entry
);
70 void identifyStoreObject();
71 void identifyFoundObject(StoreEntry
*entry
);
72 int storeOKTransferDone() const;
73 int storeNotOKTransferDone() const;
74 /// replaces current response store entry with the given one
75 void setReplyToStoreEntry(StoreEntry
*e
);
76 /// builds error using clientBuildError() and calls setReplyToError() below
77 void setReplyToError(err_type
, http_status
, const HttpRequestMethod
&, char const *, Ip::Address
&, HttpRequest
*, const char *,
79 Auth::UserRequest::Pointer
);
83 /// creates a store entry for the reply and appends err to it
84 void setReplyToError(const HttpRequestMethod
& method
, ErrorState
*err
);
85 void createStoreEntry(const HttpRequestMethod
& m
, request_flags flags
);
86 void removeStoreReference(store_client
** scp
, StoreEntry
** ep
);
87 void removeClientStoreReference(store_client
**scp
, ClientHttpRequest
*http
);
88 void startError(ErrorState
* err
);
89 void processExpired();
90 clientStream_status_t
replyStatus();
92 void traceReply(clientStreamNode
* node
);
94 http_status purgeStatus
;
96 /* state variable - replace with class to handle storeentries at some point */
98 virtual void created (StoreEntry
*newEntry
);
100 ClientHttpRequest
*http
;
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 */
107 char tempbuf
[HTTP_REQBUF_SZ
]; /* a temporary buffer if we need working storage */
108 #if USE_CACHE_DIGESTS
110 const char *lookup_type
; /* temporary hack: storeGet() result: HIT/MISS/NONE */
115 unsigned storelogiccomplete
:1;
117 unsigned complete
:1; /* we have read all we can from upstream */
120 clientStreamNode
*ourNode
; /* This will go away if/when this file gets refactored some more */
123 CBDATA_CLASS(clientReplyContext
);
124 clientStreamNode
*getNextNode() const;
126 bool errorInStream(StoreIOBuffer
const &result
, size_t const &sizeToProcess
)const ;
127 void sendStreamError(StoreIOBuffer
const &result
);
128 void pushStreamData(StoreIOBuffer
const &result
, char *source
);
129 clientStreamNode
* next() const;
130 StoreIOBuffer holdingBuffer
;
132 void processReplyAccess();
133 static ACLCB ProcessReplyAccessResult
;
134 void processReplyAccessResult(const allow_t
&accessAllowed
);
136 void buildReplyHeader ();
137 bool alwaysAllowResponse(http_status sline
) const;
138 int checkTransferDone();
139 void processOnlyIfCachedMiss();
140 void processConditional(StoreIOBuffer
&result
);
141 void cacheHit(StoreIOBuffer result
);
142 void handleIMSReply(StoreIOBuffer result
);
143 void sendMoreData(StoreIOBuffer result
);
144 void triggerInitialStoreRead();
145 void sendClientOldEntry();
146 void purgeAllCached();
148 void sendBodyTooLargeError();
149 void sendPreconditionFailedError();
150 void sendNotModified();
151 void sendNotModifiedOrPreconditionFailedError();
153 StoreEntry
*old_entry
;
154 store_client
*old_sc
; /* ... for entry to be validated */
158 #endif /* SQUID_CLIENTSIDEREPLY_H */