]> git.ipfire.org Git - thirdparty/squid.git/blob - src/http.h
Merge from trunk rev.13584
[thirdparty/squid.git] / src / http.h
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 "comm.h"
13 #include "HttpStateFlags.h"
14 #include "Server.h"
15
16 class ChunkedCodingParser;
17 class FwdState;
18 class HttpHeader;
19
20 class HttpStateData : public ServerStateData
21 {
22
23 public:
24 HttpStateData(FwdState *);
25 ~HttpStateData();
26
27 static void httpBuildRequestHeader(HttpRequest * request,
28 StoreEntry * entry,
29 const AccessLogEntryPointer &al,
30 HttpHeader * hdr_out,
31 const HttpStateFlags &flags);
32
33 virtual const Comm::ConnectionPointer & dataConnection() const;
34 /* should be private */
35 bool sendRequest();
36 void processReplyHeader();
37 void processReplyBody();
38 void readReply(const CommIoCbParams &io);
39 virtual void maybeReadVirginBody(); // read response data from the network
40
41 // Determine whether the response is a cacheable representation
42 int cacheableReply();
43
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 */
47 HttpStateFlags flags;
48 size_t read_sz;
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
52 MemBuf *readBuf;
53 bool ignoreCacheControl;
54 bool surrogateNoStore;
55
56 void processSurrogateControl(HttpReply *);
57
58 protected:
59 void processReply();
60 void proceedAfter1xx();
61 void handle1xx(HttpReply *msg);
62
63 private:
64 /**
65 * The current server connection.
66 * Maybe open, closed, or NULL.
67 * Use doneWithServer() to check if the server is available for use.
68 */
69 Comm::ConnectionPointer serverConnection;
70 AsyncCall::Pointer closeHandler;
71 enum ConnectionStatus {
72 INCOMPLETE_MSG,
73 COMPLETE_PERSISTENT_MSG,
74 COMPLETE_NONPERSISTENT_MSG
75 };
76 ConnectionStatus statusIfComplete() const;
77 ConnectionStatus persistentConnStatus() const;
78 void keepaliveAccounting(HttpReply *);
79 void checkDateSkew(HttpReply *);
80
81 bool continueAfterParsingHeader();
82 void truncateVirginBody();
83
84 virtual void start();
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;
91
92 // consuming request body
93 virtual void handleMoreRequestBodyAvailable();
94 virtual void handleRequestBodyProducerAborted();
95
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);
104 void sendComplete();
105 void httpStateConnClosed(const CommCloseCbParams &params);
106 void httpTimeout(const CommTimeoutCbParams &params);
107
108 mb_size_t buildRequestPrefix(MemBuf * mb);
109 static bool decideIfWeDoRanges (HttpRequest * orig_request);
110 bool peerSupportsConnectionPinning() const;
111
112 ChunkedCodingParser *httpChunkDecoder;
113 private:
114 CBDATA_CLASS2(HttpStateData);
115 };
116
117 int httpCachable(const HttpRequestMethod&);
118 void httpStart(FwdState *);
119 const char *httpMakeVaryMark(HttpRequest * request, HttpReply const * reply);
120
121 #endif /* SQUID_HTTP_H */