]>
Commit | Line | Data |
---|---|---|
e6ccf245 | 1 | /* |
bbc27441 | 2 | * Copyright (C) 1996-2014 The Squid Software Foundation and contributors |
e6ccf245 | 3 | * |
bbc27441 AJ |
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. | |
e6ccf245 | 7 | */ |
8 | ||
9 | #ifndef SQUID_HTTP_H | |
10 | #define SQUID_HTTP_H | |
11 | ||
fccd4a86 | 12 | #include "clients/Client.h" |
c4b7a5a9 | 13 | #include "comm.h" |
46f4b111 | 14 | #include "HttpStateFlags.h" |
314782d4 FC |
15 | |
16 | class ChunkedCodingParser; | |
17 | class FwdState; | |
c6983ec7 | 18 | class HttpHeader; |
e6ccf245 | 19 | |
fccd4a86 | 20 | class HttpStateData : public Client |
62e76326 | 21 | { |
5c2f68b7 | 22 | CBDATA_CLASS(HttpStateData); |
62e76326 | 23 | |
24 | public: | |
11913361 | 25 | HttpStateData(FwdState *); |
2afaba07 | 26 | ~HttpStateData(); |
27 | ||
99d4c5e0 | 28 | static void httpBuildRequestHeader(HttpRequest * request, |
99d4c5e0 | 29 | StoreEntry * entry, |
4bf68cfa | 30 | const AccessLogEntryPointer &al, |
99d4c5e0 | 31 | HttpHeader * hdr_out, |
46f4b111 | 32 | const HttpStateFlags &flags); |
5f8252d2 | 33 | |
e83cc785 | 34 | virtual const Comm::ConnectionPointer & dataConnection() const; |
4eb368f9 | 35 | /* should be private */ |
5f8252d2 | 36 | bool sendRequest(); |
2afaba07 | 37 | void processReplyHeader(); |
38 | void processReplyBody(); | |
dc56a9b1 | 39 | void readReply(const CommIoCbParams &io); |
5f8252d2 | 40 | virtual void maybeReadVirginBody(); // read response data from the network |
2b59002c AJ |
41 | |
42 | // Determine whether the response is a cacheable representation | |
924f73bc | 43 | int cacheableReply(); |
2afaba07 | 44 | |
a3c6762c | 45 | CachePeer *_peer; /* CachePeer request made to */ |
e6ccf245 | 46 | int eof; /* reached end-of-object? */ |
839291ac | 47 | int lastChunk; /* reached last chunk of a chunk-encoded reply */ |
46f4b111 | 48 | HttpStateFlags flags; |
c4b7a5a9 | 49 | size_t read_sz; |
5f8252d2 | 50 | int header_bytes_read; // to find end of response, |
3a9c37f7 | 51 | int64_t reply_bytes_read; // without relying on StoreEntry |
821beb5e | 52 | int body_bytes_truncated; // positive when we read more than we wanted |
2afaba07 | 53 | MemBuf *readBuf; |
43ae1d95 | 54 | bool ignoreCacheControl; |
55 | bool surrogateNoStore; | |
5f8252d2 | 56 | |
43ae1d95 | 57 | void processSurrogateControl(HttpReply *); |
2afaba07 | 58 | |
7c4e4e7f | 59 | protected: |
655daa06 AR |
60 | void processReply(); |
61 | void proceedAfter1xx(); | |
62 | void handle1xx(HttpReply *msg); | |
63 | ||
528b2c61 | 64 | private: |
8d71285d AJ |
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; | |
dc56a9b1 | 71 | AsyncCall::Pointer closeHandler; |
528b2c61 | 72 | enum ConnectionStatus { |
62e76326 | 73 | INCOMPLETE_MSG, |
74 | COMPLETE_PERSISTENT_MSG, | |
75 | COMPLETE_NONPERSISTENT_MSG | |
528b2c61 | 76 | }; |
77 | ConnectionStatus statusIfComplete() const; | |
78 | ConnectionStatus persistentConnStatus() const; | |
2afaba07 | 79 | void keepaliveAccounting(HttpReply *); |
80 | void checkDateSkew(HttpReply *); | |
5f8252d2 | 81 | |
ba82c452 | 82 | bool continueAfterParsingHeader(); |
821beb5e | 83 | void truncateVirginBody(); |
ba82c452 | 84 | |
79628299 | 85 | virtual void start(); |
5f8252d2 | 86 | virtual void haveParsedReplyHeaders(); |
39cb8c41 | 87 | virtual bool getMoreRequestBody(MemBuf &buf); |
5f8252d2 | 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 | |
aea65fec | 91 | virtual bool mayReadVirginReplyBody() const; |
5f8252d2 | 92 | |
93 | // consuming request body | |
94 | virtual void handleMoreRequestBodyAvailable(); | |
95 | virtual void handleRequestBodyProducerAborted(); | |
96 | ||
97 | void writeReplyBody(); | |
af0bb8e5 | 98 | bool decodeAndWriteReplyBody(); |
39cb8c41 AR |
99 | bool finishingBrokenPost(); |
100 | bool finishingChunkedRequest(); | |
5f8252d2 | 101 | void doneSendingRequestBody(); |
3b299123 | 102 | void requestBodyHandler(MemBuf &); |
dc56a9b1 | 103 | virtual void sentRequestBody(const CommIoCbParams &io); |
39cb8c41 AR |
104 | void wroteLast(const CommIoCbParams &io); |
105 | void sendComplete(); | |
dc56a9b1 | 106 | void httpStateConnClosed(const CommCloseCbParams ¶ms); |
107 | void httpTimeout(const CommTimeoutCbParams ¶ms); | |
108 | ||
e24f13cd | 109 | mb_size_t buildRequestPrefix(MemBuf * mb); |
99d4c5e0 | 110 | static bool decideIfWeDoRanges (HttpRequest * orig_request); |
d67acb4e | 111 | bool peerSupportsConnectionPinning() const; |
2afaba07 | 112 | |
af0bb8e5 | 113 | ChunkedCodingParser *httpChunkDecoder; |
e6ccf245 | 114 | }; |
115 | ||
8a648e8d FC |
116 | int httpCachable(const HttpRequestMethod&); |
117 | void httpStart(FwdState *); | |
118 | const char *httpMakeVaryMark(HttpRequest * request, HttpReply const * reply); | |
fc54b8d2 | 119 | |
e6ccf245 | 120 | #endif /* SQUID_HTTP_H */ |