]> git.ipfire.org Git - thirdparty/squid.git/blame_incremental - src/http.h
Extend Client API to estimate needed buffer space using an SBuf
[thirdparty/squid.git] / src / http.h
... / ...
CommitLineData
1/*
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9#ifndef SQUID_HTTP_H
10#define SQUID_HTTP_H
11
12#include "clients/Client.h"
13#include "comm.h"
14#include "HttpStateFlags.h"
15
16class ChunkedCodingParser;
17class FwdState;
18class HttpHeader;
19
20class HttpStateData : public Client
21{
22 CBDATA_CLASS(HttpStateData);
23
24public:
25 HttpStateData(FwdState *);
26 ~HttpStateData();
27
28 static void httpBuildRequestHeader(HttpRequest * request,
29 StoreEntry * entry,
30 const AccessLogEntryPointer &al,
31 HttpHeader * hdr_out,
32 const HttpStateFlags &flags);
33
34 virtual const Comm::ConnectionPointer & dataConnection() const;
35 /* should be private */
36 bool sendRequest();
37 void processReplyHeader();
38 void processReplyBody();
39 void readReply(const CommIoCbParams &io);
40 virtual void maybeReadVirginBody(); // read response data from the network
41
42 // Determine whether the response is a cacheable representation
43 int cacheableReply();
44
45 CachePeer *_peer; /* CachePeer request made to */
46 int eof; /* reached end-of-object? */
47 int lastChunk; /* reached last chunk of a chunk-encoded reply */
48 HttpStateFlags flags;
49 size_t read_sz;
50 int header_bytes_read; // to find end of response,
51 int64_t reply_bytes_read; // without relying on StoreEntry
52 int body_bytes_truncated; // positive when we read more than we wanted
53 MemBuf *readBuf;
54 bool ignoreCacheControl;
55 bool surrogateNoStore;
56
57 void processSurrogateControl(HttpReply *);
58
59protected:
60 void processReply();
61 void proceedAfter1xx();
62 void handle1xx(HttpReply *msg);
63
64private:
65 /**
66 * The current server connection.
67 * Maybe open, closed, or NULL.
68 * Use doneWithServer() to check if the server is available for use.
69 */
70 Comm::ConnectionPointer serverConnection;
71 AsyncCall::Pointer closeHandler;
72 enum ConnectionStatus {
73 INCOMPLETE_MSG,
74 COMPLETE_PERSISTENT_MSG,
75 COMPLETE_NONPERSISTENT_MSG
76 };
77 ConnectionStatus statusIfComplete() const;
78 ConnectionStatus persistentConnStatus() const;
79 void keepaliveAccounting(HttpReply *);
80 void checkDateSkew(HttpReply *);
81
82 bool continueAfterParsingHeader();
83 void truncateVirginBody();
84
85 virtual void start();
86 virtual void haveParsedReplyHeaders();
87 virtual bool getMoreRequestBody(MemBuf &buf);
88 virtual void closeServer(); // end communication with the server
89 virtual bool doneWithServer() const; // did we end communication?
90 virtual void abortTransaction(const char *reason); // abnormal termination
91 virtual bool mayReadVirginReplyBody() const;
92
93 // consuming request body
94 virtual void handleMoreRequestBodyAvailable();
95 virtual void handleRequestBodyProducerAborted();
96
97 void writeReplyBody();
98 bool decodeAndWriteReplyBody();
99 bool finishingBrokenPost();
100 bool finishingChunkedRequest();
101 void doneSendingRequestBody();
102 void requestBodyHandler(MemBuf &);
103 virtual void sentRequestBody(const CommIoCbParams &io);
104 void wroteLast(const CommIoCbParams &io);
105 void sendComplete();
106 void httpStateConnClosed(const CommCloseCbParams &params);
107 void httpTimeout(const CommTimeoutCbParams &params);
108
109 mb_size_t buildRequestPrefix(MemBuf * mb);
110 static bool decideIfWeDoRanges (HttpRequest * orig_request);
111 bool peerSupportsConnectionPinning() const;
112
113 ChunkedCodingParser *httpChunkDecoder;
114};
115
116int httpCachable(const HttpRequestMethod&);
117void httpStart(FwdState *);
118const char *httpMakeVaryMark(HttpRequest * request, HttpReply const * reply);
119
120#endif /* SQUID_HTTP_H */