/*
- * $Id: client_side_request.h,v 1.19 2003/09/01 03:49:38 robertc Exp $
+ * $Id$
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
*/
+
#ifndef SQUID_CLIENTSIDEREQUEST_H
#define SQUID_CLIENTSIDEREQUEST_H
+#include "squid.h"
#include "HttpHeader.h"
#include "clientStream.h"
#include "client_side.h"
#include "AccessLogEntry.h"
+#include "dlink.h"
+#include "base/AsyncJob.h"
+
+#if USE_ADAPTATION
+#include "adaptation/forward.h"
+#include "adaptation/Initiator.h"
+
+class HttpMsg;
+#endif
/* client_side_request.c - client side request related routines (pure logic) */
-extern int clientBeginRequest(method_t, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t);
+extern int clientBeginRequest(const HttpRequestMethod&, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t);
class MemObject;
-typedef class ClientHttpRequest clientHttpRequest;
-
class ConnStateData;
+class ClientRequestContext;
+
class ClientHttpRequest
+#if USE_ADAPTATION
+ : public Adaptation::Initiator, // to start adaptation transactions
+ public BodyConsumer // to receive reply bodies in request satisf. mode
+#endif
{
public:
void *operator new (size_t);
void operator delete (void *);
-
- ClientHttpRequest();
+#if USE_ADAPTATION
+ void *toCbdata() { return this; }
+#endif
+ ClientHttpRequest(ConnStateData *);
~ClientHttpRequest();
/* Not implemented - present to prevent synthetic operations */
ClientHttpRequest(ClientHttpRequest const &);
_SQUID_INLINE_ StoreEntry *loggingEntry() const;
void loggingEntry(StoreEntry *);
- _SQUID_INLINE_ ConnStateData::Pointer getConn();
- _SQUID_INLINE_ ConnStateData::Pointer const getConn() const;
- _SQUID_INLINE_ void setConn(ConnStateData::Pointer);
+ _SQUID_INLINE_ ConnStateData * getConn();
+ _SQUID_INLINE_ ConnStateData * const getConn() const;
+ _SQUID_INLINE_ void setConn(ConnStateData *);
HttpRequest *request; /* Parsed URL ... */
char *uri;
char *log_uri;
- struct
- {
- off_t offset;
- size_t size;
+ struct {
+ int64_t offset;
+ int64_t size;
size_t headers_sz;
- }
+ } out;
- out;
HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
size_t req_sz; /* raw request size on input, not current request size */
log_type logType;
- struct timeval start;
- HttpVersion http_ver;
+ struct timeval start_time;
AccessLogEntry al;
- struct
- {
-
-unsigned int accel:
- 1;
-
-unsigned int transparent:
- 1;
-
-unsigned int internal:
- 1;
+ struct {
+ unsigned int accel:1;
+ unsigned int intercepted:1;
+ unsigned int spoof_client_ip:1;
+ unsigned int internal:1;
+ unsigned int done_copying:1;
+ unsigned int purging:1;
+ } flags;
-unsigned int done_copying:
- 1;
-
-unsigned int purging:
- 1;
- }
-
- flags;
-
- struct
- {
+ struct {
http_status status;
char *location;
- }
+ } redirect;
- redirect;
dlink_node active;
dlink_list client_stream;
int mRangeCLen();
- ssize_t maxReplyBodySize() const;
- void maxReplyBodySize(ssize_t size);
- bool isReplyBodyTooLarge(ssize_t len) const;
+ ClientRequestContext *calloutContext;
+ void doCallouts();
+
+#if USE_ADAPTATION
+ // AsyncJob virtual methods
+ virtual bool doneAll() const {
+ return Initiator::doneAll() &&
+ BodyConsumer::doneAll() && false;
+ }
+#endif
private:
CBDATA_CLASS(ClientHttpRequest);
- ssize_t maxReplyBodySize_;
+ int64_t maxReplyBodySize_;
StoreEntry *entry_;
StoreEntry *loggingEntry_;
- ConnStateData::Pointer conn_;
+ ConnStateData * conn_;
+
+#if USE_SSL
+public:
+ bool sslBumpNeeded() const;
+ void sslBumpStart();
+ void sslBumpEstablish(comm_err_t errflag);
+#endif
+
+#if USE_ADAPTATION
+
+public:
+ void startAdaptation(const Adaptation::ServiceGroupPointer &g);
+
+ // private but exposed for ClientRequestContext
+ void handleAdaptationFailure(bool bypassable = false);
+
+private:
+ // Adaptation::Initiator API
+ virtual void noteAdaptationAnswer(HttpMsg *message);
+ virtual void noteAdaptationQueryAbort(bool final);
+
+ // BodyConsumer API, called by BodyPipe
+ virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer);
+ virtual void noteBodyProductionEnded(BodyPipe::Pointer);
+ virtual void noteBodyProducerAborted(BodyPipe::Pointer);
+
+ void endRequestSatisfaction();
+
+private:
+ Adaptation::Initiate *virginHeadSource;
+ BodyPipe::Pointer adaptedBodySource;
+
+ bool request_satisfaction_mode;
+ int64_t request_satisfaction_offset;
+#endif
};
/* client http based routines */
-SQUIDCEXTERN char *clientConstructTraceEcho(clientHttpRequest *);
-SQUIDCEXTERN ACLChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
-SQUIDCEXTERN int clientHttpRequestStatus(int fd, clientHttpRequest const *http);
+SQUIDCEXTERN char *clientConstructTraceEcho(ClientHttpRequest *);
+
+class ACLFilledChecklist;
+SQUIDCEXTERN ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
+SQUIDCEXTERN int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
SQUIDCEXTERN void clientAccessCheck(ClientHttpRequest *);
/* ones that should be elsewhere */
-SQUIDCEXTERN void redirectStart(clientHttpRequest *, RH *, void *);
+SQUIDCEXTERN void redirectStart(ClientHttpRequest *, RH *, void *);
-SQUIDCEXTERN void sslStart(clientHttpRequest *, size_t *, int *);
+SQUIDCEXTERN void tunnelStart(ClientHttpRequest *, int64_t *, int *);
#ifdef _USE_INLINE_
#include "Store.h"