3 * $Id: client_side_reply.h,v 1.18 2007/12/14 23:11:46 amosjeffries Exp $
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
32 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
35 #ifndef SQUID_CLIENTSIDEREPLY_H
36 #define SQUID_CLIENTSIDEREPLY_H
39 #include "HttpHeader.h"
40 #include "clientStream.h"
41 #include "StoreClient.h"
42 #include "client_side_request.h"
43 #include "IPAddress.h"
47 /* XXX make static method */
49 class clientReplyContext
: public RefCountable
, public StoreClient
53 void *operator new (size_t byteCount
);
54 void operator delete (void *address
);
56 static STCB HandleIMSReply
;
57 static STCB SendMoreData
;
59 clientReplyContext(ClientHttpRequest
*);
60 ~clientReplyContext();
65 void purgeRequestFindObjectToPurge();
66 void purgeDoMissPurge();
67 void purgeFoundGet(StoreEntry
*newEntry
);
68 void purgeFoundHead(StoreEntry
*newEntry
);
69 void purgeFoundObject(StoreEntry
*entry
);
70 void sendClientUpstreamResponse();
71 void purgeDoPurgeGet(StoreEntry
*entry
);
72 void purgeDoPurgeHead(StoreEntry
*entry
);
74 void identifyStoreObject();
75 void identifyFoundObject(StoreEntry
*entry
);
76 int storeOKTransferDone() const;
77 int storeNotOKTransferDone() const;
79 void setReplyToError(err_type
, http_status
, method_t
, char const *, IPAddress
&, HttpRequest
*, char *, AuthUserRequest
*);
80 void createStoreEntry(method_t m
, request_flags flags
);
81 void removeStoreReference(store_client
** scp
, StoreEntry
** ep
);
82 void removeClientStoreReference(store_client
**scp
, ClientHttpRequest
*http
);
83 void startError(ErrorState
* err
);
84 void processExpired();
85 clientStream_status_t
replyStatus();
87 void traceReply(clientStreamNode
* node
);
89 http_status purgeStatus
;
91 /* state variable - replace with class to handle storeentries at some point */
93 virtual void created (StoreEntry
*newEntry
);
95 ClientHttpRequest
*http
;
97 store_client
*sc
; /* The store_client we're using */
98 StoreIOBuffer tempBuffer
; /* For use in validating requests via IMS */
99 int old_reqsize
; /* ... again, for the buffer */
102 char tempbuf
[HTTP_REQBUF_SZ
]; /* a temporary buffer if we need working storage */
103 #if USE_CACHE_DIGESTS
105 const char *lookup_type
; /* temporary hack: storeGet() result: HIT/MISS/NONE */
111 unsigned storelogiccomplete
: 1;
113 unsigned complete
: 1; /* we have read all we can from upstream */
118 clientStreamNode
*ourNode
; /* This will go away if/when this file gets refactored some more */
121 CBDATA_CLASS(clientReplyContext
);
122 clientStreamNode
*getNextNode() const;
124 bool errorInStream(StoreIOBuffer
const &result
, size_t const &sizeToProcess
)const ;
125 void sendStreamError(StoreIOBuffer
const &result
);
126 void pushStreamData(StoreIOBuffer
const &result
, char *source
);
127 void waitForMoreData ();
128 clientStreamNode
* next() const;
129 void startSendProcess();
130 StoreIOBuffer holdingBuffer
;
132 void processReplyAccess();
133 static PF ProcessReplyAccessResult
;
134 void processReplyAccessResult(bool accessAllowed
);
135 void buildReply(const char *buf
, size_t size
);
136 void buildReplyHeader ();
137 bool alwaysAllowResponse(http_status sline
) const;
138 int checkTransferDone();
139 void processOnlyIfCachedMiss();
140 void cacheHit(StoreIOBuffer result
);
141 void handleIMSReply(StoreIOBuffer result
);
142 void sendMoreData(StoreIOBuffer result
);
143 void triggerInitialStoreRead();
144 void sendClientOldEntry();
145 void buildMaxBodySize(HttpReply
* reply
);
148 StoreEntry
*old_entry
;
149 store_client
*old_sc
; /* ... for entry to be validated */
153 #endif /* SQUID_CLIENTSIDEREPLY_H */