3 * $Id: client_side.h,v 1.8 2003/08/10 11:00:42 robertc 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.
34 #ifndef SQUID_CLIENTSIDE_H
35 #define SQUID_CLIENTSIDE_H
37 #include "StoreIOBuffer.h"
42 class ClientHttpRequest
;
44 class clientStreamNode
;
50 class ClientSocketContext
: public RefCountable
54 typedef RefCount
<ClientSocketContext
> Pointer
;
55 void *operator new(size_t);
56 void operator delete(void *);
57 ClientSocketContext();
58 ~ClientSocketContext();
59 bool startOfOutput() const;
60 void writeComplete(int fd
, char *bufnotused
, size_t size
, comm_err_t errflag
);
61 void keepaliveNextRequest();
62 ClientHttpRequest
*http
; /* we own this */
63 char reqbuf
[HTTP_REQBUF_SZ
];
70 1; /* This is a pipelined request waiting for the current object to complete */
73 1; /* Was this parsed correctly? */
77 bool mayUseConnection() const {return mayUseConnection_
;}
79 void mayUseConnection(bool aBool
)
81 mayUseConnection_
= aBool
;
82 debug (33,3)("ClientSocketContext::mayUseConnection: This %p marked %d\n",
90 clientStreamNode
*node
;
92 StoreIOBuffer queuedBuffer
;
95 DeferredParams deferredparams
;
96 off_t writtenToSocket
;
98 off_t
getNextRangeOffset() const;
99 bool canPackMoreRanges() const;
100 clientStream_status_t
socketState();
101 void sendBody(HttpReply
* rep
, StoreIOBuffer bodyData
);
102 void sendStartOfMessage(HttpReply
* rep
, StoreIOBuffer bodyData
);
103 size_t lengthToSend(Range
<size_t> const &available
);
104 void noteSentBodyBytes(size_t);
105 void buildRangeHeader(HttpReply
* rep
);
107 clientStreamNode
* getTail() const;
108 clientStreamNode
* getClientReplyContext() const;
109 void connIsFinished();
110 void removeFromConnectionList(RefCount
<ConnStateData
> conn
);
111 void deferRecipientForLater(clientStreamNode
* node
, HttpReply
* rep
, StoreIOBuffer recievedData
);
112 bool multipartRangeRequest() const;
113 void registerWithConn();
116 CBDATA_CLASS(ClientSocketContext
);
117 void prepareReply(HttpReply
* rep
);
118 void packRange(StoreIOBuffer
const &, MemBuf
* mb
);
119 void deRegisterWithConn();
120 bool mayUseConnection_
; /* This request may use the connection. Don't read anymore requests for now */
121 bool connRegistered_
;
124 class ConnStateData
: public RefCountable
128 typedef RefCount
<ConnStateData
> Pointer
;
129 void * operator new (size_t);
130 void operator delete (void *);
136 int getAvailableBufferLength() const;
137 bool areAllContextsForThisConnection() const;
138 void freeAllContexts();
139 void readNextRequest();
140 void makeSpaceAvailable();
141 ClientSocketContext::Pointer
getCurrentContext() const;
142 void addContextToQueue(ClientSocketContext
* context
);
143 int getConcurrentRequestCount() const;
153 char *addressToReadInto() const;
156 size_t allocatedSize
;
163 size_t size_left
; /* How much body left to process */
164 HttpRequest
*request
; /* Parameters passed to clientReadBody */
172 auth_type_t auth_type
; /* Is this connection based authentication? if so what type it is. */
173 /* note this is ONLY connection based because NTLM is against HTTP spec */
174 /* the user details for connection based authentication */
175 auth_user_request_t
*auth_user_request
;
176 /* TODO: generalise the connection owner concept */
177 ClientSocketContext::Pointer currentobject
; /* used by the owner of the connection. Opaque otherwise */
179 struct sockaddr_in peer
;
181 struct sockaddr_in me
;
183 struct in_addr log_addr
;
184 char rfc931
[USER_IDENT_SZ
];
190 int readMoreRequests
:
195 http_port_list
*port
;
197 bool transparent() const;
198 void transparent(bool const);
199 bool reading() const;
200 void reading(bool const);
203 CBDATA_CLASS(ConnStateData
);
206 Pointer openReference
;
209 #endif /* SQUID_CLIENTSIDE_H */