]> git.ipfire.org Git - thirdparty/squid.git/blame - src/http.h
Polish rev.13980 debugs
[thirdparty/squid.git] / src / http.h
CommitLineData
e6ccf245 1/*
bde978a6 2 * Copyright (C) 1996-2015 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
16class ChunkedCodingParser;
17class FwdState;
c6983ec7 18class HttpHeader;
e6ccf245 19
fccd4a86 20class HttpStateData : public Client
62e76326 21{
5c2f68b7 22 CBDATA_CLASS(HttpStateData);
62e76326 23
24public:
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
f53969cc
SM
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 */
46f4b111 48 HttpStateFlags flags;
c4b7a5a9 49 size_t read_sz;
395a814a 50 SBuf inBuf; ///< I/O buffer for receiving server responses
43ae1d95 51 bool ignoreCacheControl;
52 bool surrogateNoStore;
5f8252d2 53
43ae1d95 54 void processSurrogateControl(HttpReply *);
2afaba07 55
7c4e4e7f 56protected:
655daa06
AR
57 void processReply();
58 void proceedAfter1xx();
59 void handle1xx(HttpReply *msg);
60
528b2c61 61private:
8d71285d
AJ
62 /**
63 * The current server connection.
64 * Maybe open, closed, or NULL.
65 * Use doneWithServer() to check if the server is available for use.
66 */
67 Comm::ConnectionPointer serverConnection;
dc56a9b1 68 AsyncCall::Pointer closeHandler;
528b2c61 69 enum ConnectionStatus {
62e76326 70 INCOMPLETE_MSG,
71 COMPLETE_PERSISTENT_MSG,
72 COMPLETE_NONPERSISTENT_MSG
528b2c61 73 };
74 ConnectionStatus statusIfComplete() const;
75 ConnectionStatus persistentConnStatus() const;
2afaba07 76 void keepaliveAccounting(HttpReply *);
77 void checkDateSkew(HttpReply *);
5f8252d2 78
ba82c452 79 bool continueAfterParsingHeader();
821beb5e 80 void truncateVirginBody();
ba82c452 81
79628299 82 virtual void start();
5f8252d2 83 virtual void haveParsedReplyHeaders();
39cb8c41 84 virtual bool getMoreRequestBody(MemBuf &buf);
5f8252d2 85 virtual void closeServer(); // end communication with the server
86 virtual bool doneWithServer() const; // did we end communication?
87 virtual void abortTransaction(const char *reason); // abnormal termination
aea65fec 88 virtual bool mayReadVirginReplyBody() const;
5f8252d2 89
90 // consuming request body
91 virtual void handleMoreRequestBodyAvailable();
92 virtual void handleRequestBodyProducerAborted();
93
94 void writeReplyBody();
af0bb8e5 95 bool decodeAndWriteReplyBody();
39cb8c41
AR
96 bool finishingBrokenPost();
97 bool finishingChunkedRequest();
5f8252d2 98 void doneSendingRequestBody();
3b299123 99 void requestBodyHandler(MemBuf &);
dc56a9b1 100 virtual void sentRequestBody(const CommIoCbParams &io);
39cb8c41
AR
101 void wroteLast(const CommIoCbParams &io);
102 void sendComplete();
dc56a9b1 103 void httpStateConnClosed(const CommCloseCbParams &params);
104 void httpTimeout(const CommTimeoutCbParams &params);
105
e24f13cd 106 mb_size_t buildRequestPrefix(MemBuf * mb);
99d4c5e0 107 static bool decideIfWeDoRanges (HttpRequest * orig_request);
d67acb4e 108 bool peerSupportsConnectionPinning() const;
2afaba07 109
f542211b
AJ
110 /// Parser being used at present to parse the HTTP/ICY server response.
111 Http1::ResponseParserPointer hp;
af0bb8e5 112 ChunkedCodingParser *httpChunkDecoder;
8e100780
AJ
113
114 /// amount of message payload/body received so far.
115 int64_t payloadSeen;
116 /// positive when we read more than we wanted
117 int64_t payloadTruncated;
e6ccf245 118};
119
8a648e8d
FC
120int httpCachable(const HttpRequestMethod&);
121void httpStart(FwdState *);
122const char *httpMakeVaryMark(HttpRequest * request, HttpReply const * reply);
fc54b8d2 123
e6ccf245 124#endif /* SQUID_HTTP_H */
f53969cc 125