4 * SQUID Web Proxy Cache http://www.squid-cache.org/
5 * ----------------------------------------------------------
7 * Squid is the result of efforts by numerous individuals from
8 * the Internet community; see the CONTRIBUTORS file for full
9 * details. Many organizations have provided support for Squid's
10 * development; see the SPONSORS file for full details. Squid is
11 * Copyrighted (C) 2001 by the Regents of the University of
12 * California; see the COPYRIGHT file for full details. Squid
13 * incorporates software developed and/or copyrighted by other
14 * sources; see the CREDITS file for full details.
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
36 #include "HttpStateFlags.h"
39 class ChunkedCodingParser
;
43 class HttpStateData
: public ServerStateData
47 HttpStateData(FwdState
*);
50 static void httpBuildRequestHeader(HttpRequest
* request
,
52 const AccessLogEntryPointer
&al
,
54 const HttpStateFlags
&flags
);
56 virtual const Comm::ConnectionPointer
& dataConnection() const;
57 /* should be private */
59 void processReplyHeader();
60 void processReplyBody();
61 void readReply(const CommIoCbParams
&io
);
62 virtual void maybeReadVirginBody(); // read response data from the network
64 // Determine whether the response is a cacheable representation
67 CachePeer
*_peer
; /* CachePeer request made to */
68 int eof
; /* reached end-of-object? */
69 int lastChunk
; /* reached last chunk of a chunk-encoded reply */
72 int header_bytes_read
; // to find end of response,
73 int64_t reply_bytes_read
; // without relying on StoreEntry
74 int body_bytes_truncated
; // positive when we read more than we wanted
76 bool ignoreCacheControl
;
77 bool surrogateNoStore
;
79 void processSurrogateControl(HttpReply
*);
83 void proceedAfter1xx();
84 void handle1xx(HttpReply
*msg
);
88 * The current server connection.
89 * Maybe open, closed, or NULL.
90 * Use doneWithServer() to check if the server is available for use.
92 Comm::ConnectionPointer serverConnection
;
93 AsyncCall::Pointer closeHandler
;
94 enum ConnectionStatus
{
96 COMPLETE_PERSISTENT_MSG
,
97 COMPLETE_NONPERSISTENT_MSG
99 ConnectionStatus
statusIfComplete() const;
100 ConnectionStatus
persistentConnStatus() const;
101 void keepaliveAccounting(HttpReply
*);
102 void checkDateSkew(HttpReply
*);
104 bool continueAfterParsingHeader();
105 void truncateVirginBody();
107 virtual void start();
108 virtual void haveParsedReplyHeaders();
109 virtual bool getMoreRequestBody(MemBuf
&buf
);
110 virtual void closeServer(); // end communication with the server
111 virtual bool doneWithServer() const; // did we end communication?
112 virtual void abortTransaction(const char *reason
); // abnormal termination
114 // consuming request body
115 virtual void handleMoreRequestBodyAvailable();
116 virtual void handleRequestBodyProducerAborted();
118 void writeReplyBody();
119 bool decodeAndWriteReplyBody();
120 bool finishingBrokenPost();
121 bool finishingChunkedRequest();
122 void doneSendingRequestBody();
123 void requestBodyHandler(MemBuf
&);
124 virtual void sentRequestBody(const CommIoCbParams
&io
);
125 void wroteLast(const CommIoCbParams
&io
);
127 void httpStateConnClosed(const CommCloseCbParams
¶ms
);
128 void httpTimeout(const CommTimeoutCbParams
¶ms
);
130 mb_size_t
buildRequestPrefix(MemBuf
* mb
);
131 static bool decideIfWeDoRanges (HttpRequest
* orig_request
);
132 bool peerSupportsConnectionPinning() const;
134 ChunkedCodingParser
*httpChunkDecoder
;
136 CBDATA_CLASS2(HttpStateData
);
139 int httpCachable(const HttpRequestMethod
&);
140 void httpStart(FwdState
*);
141 const char *httpMakeVaryMark(HttpRequest
* request
, HttpReply
const * reply
);
143 #endif /* SQUID_HTTP_H */