2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
13 #include "HttpStateFlags.h"
16 class ChunkedCodingParser
;
20 class HttpStateData
: public ServerStateData
24 HttpStateData(FwdState
*);
27 static void httpBuildRequestHeader(HttpRequest
* request
,
29 const AccessLogEntryPointer
&al
,
31 const HttpStateFlags
&flags
);
33 virtual const Comm::ConnectionPointer
& dataConnection() const;
34 /* should be private */
36 void processReplyHeader();
37 void processReplyBody();
38 void readReply(const CommIoCbParams
&io
);
39 virtual void maybeReadVirginBody(); // read response data from the network
41 // Determine whether the response is a cacheable representation
44 CachePeer
*_peer
; /* CachePeer request made to */
45 int eof
; /* reached end-of-object? */
46 int lastChunk
; /* reached last chunk of a chunk-encoded reply */
49 int header_bytes_read
; // to find end of response,
50 int64_t reply_bytes_read
; // without relying on StoreEntry
51 int body_bytes_truncated
; // positive when we read more than we wanted
53 bool ignoreCacheControl
;
54 bool surrogateNoStore
;
56 void processSurrogateControl(HttpReply
*);
60 void proceedAfter1xx();
61 void handle1xx(HttpReply
*msg
);
65 * The current server connection.
66 * Maybe open, closed, or NULL.
67 * Use doneWithServer() to check if the server is available for use.
69 Comm::ConnectionPointer serverConnection
;
70 AsyncCall::Pointer closeHandler
;
71 enum ConnectionStatus
{
73 COMPLETE_PERSISTENT_MSG
,
74 COMPLETE_NONPERSISTENT_MSG
76 ConnectionStatus
statusIfComplete() const;
77 ConnectionStatus
persistentConnStatus() const;
78 void keepaliveAccounting(HttpReply
*);
79 void checkDateSkew(HttpReply
*);
81 bool continueAfterParsingHeader();
82 void truncateVirginBody();
85 virtual void haveParsedReplyHeaders();
86 virtual bool getMoreRequestBody(MemBuf
&buf
);
87 virtual void closeServer(); // end communication with the server
88 virtual bool doneWithServer() const; // did we end communication?
89 virtual void abortTransaction(const char *reason
); // abnormal termination
90 virtual bool mayReadVirginReplyBody() const;
92 // consuming request body
93 virtual void handleMoreRequestBodyAvailable();
94 virtual void handleRequestBodyProducerAborted();
96 void writeReplyBody();
97 bool decodeAndWriteReplyBody();
98 bool finishingBrokenPost();
99 bool finishingChunkedRequest();
100 void doneSendingRequestBody();
101 void requestBodyHandler(MemBuf
&);
102 virtual void sentRequestBody(const CommIoCbParams
&io
);
103 void wroteLast(const CommIoCbParams
&io
);
105 void httpStateConnClosed(const CommCloseCbParams
¶ms
);
106 void httpTimeout(const CommTimeoutCbParams
¶ms
);
108 mb_size_t
buildRequestPrefix(MemBuf
* mb
);
109 static bool decideIfWeDoRanges (HttpRequest
* orig_request
);
110 bool peerSupportsConnectionPinning() const;
112 ChunkedCodingParser
*httpChunkDecoder
;
114 CBDATA_CLASS2(HttpStateData
);
117 int httpCachable(const HttpRequestMethod
&);
118 void httpStart(FwdState
*);
119 const char *httpMakeVaryMark(HttpRequest
* request
, HttpReply
const * reply
);
121 #endif /* SQUID_HTTP_H */