http.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2020 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 "http/forward.h"
15 #include "http/StateFlags.h"
16 #include "sbuf/SBuf.h"
17 
18 class FwdState;
19 class HttpHeader;
20 class String;
21 
22 class HttpStateData : public Client
23 {
25 
26 public:
27 
30  {
31  public:
33 
36  Answers make(const Answers ans, const char *why);
37 
39  const char *reason;
40  const StoreEntry *entry;
42  };
43 
46 
48  StoreEntry * entry,
49  const AccessLogEntryPointer &al,
50  HttpHeader * hdr_out,
51  const Http::StateFlags &flags);
52 
53  virtual const Comm::ConnectionPointer & dataConnection() const;
54  /* should be private */
55  bool sendRequest();
56  void processReplyHeader();
57  void processReplyBody();
58  void readReply(const CommIoCbParams &io);
59  virtual void maybeReadVirginBody(); // read response data from the network
60 
61  // Checks whether the response is cacheable/shareable.
63 
64  CachePeer *_peer; /* CachePeer request made to */
65  int eof; /* reached end-of-object? */
66  int lastChunk; /* reached last chunk of a chunk-encoded reply */
68  size_t read_sz;
72 
75 
77 
78 protected:
79  void processReply();
80  void proceedAfter1xx();
81  void handle1xx(HttpReply *msg);
82  void drop1xx(const char *reason);
83 
84 private:
96  };
100  void checkDateSkew(HttpReply *);
101 
103  void truncateVirginBody();
104 
105  virtual void start();
106  virtual void haveParsedReplyHeaders();
107  virtual bool getMoreRequestBody(MemBuf &buf);
108  virtual void closeServer(); // end communication with the server
109  virtual bool doneWithServer() const; // did we end communication?
110  virtual void abortAll(const char *reason); // abnormal termination
111  virtual bool mayReadVirginReplyBody() const;
112 
113  void abortTransaction(const char *reason) { abortAll(reason); } // abnormal termination
114 
124  bool maybeMakeSpaceAvailable(bool grow);
125 
126  // consuming request body
127  virtual void handleMoreRequestBodyAvailable();
128  virtual void handleRequestBodyProducerAborted();
129 
130  void writeReplyBody();
132  bool finishingBrokenPost();
134  void doneSendingRequestBody();
135  void requestBodyHandler(MemBuf &);
136  virtual void sentRequestBody(const CommIoCbParams &io);
137  void wroteLast(const CommIoCbParams &io);
138  void sendComplete();
139  void httpStateConnClosed(const CommCloseCbParams &params);
140  void httpTimeout(const CommTimeoutCbParams &params);
141 
143  void forwardUpgrade(HttpHeader&);
144  static bool decideIfWeDoRanges (HttpRequest * orig_request);
145  bool peerSupportsConnectionPinning() const;
146  const char *blockSwitchingProtocols(const HttpReply&) const;
147 
151 
153  int64_t payloadSeen;
156 
160 };
161 
162 std::ostream &operator <<(std::ostream &os, const HttpStateData::ReuseDecision &d);
163 
164 int httpCachable(const HttpRequestMethod&);
165 void httpStart(FwdState *);
167 
168 #endif /* SQUID_HTTP_H */
169 
void drop1xx(const char *reason)
Definition: http.cc:851
virtual void haveParsedReplyHeaders()
called when we have final (possibly adapted) reply headers; kids extend
Definition: http.cc:983
bool maybeMakeSpaceAvailable(bool grow)
Definition: http.cc:1633
void truncateVirginBody()
Definition: http.cc:1417
StoreEntry * entry
Definition: Client.h:164
bool ignoreCacheControl
Definition: http.h:70
Definition: Client.h:29
virtual bool getMoreRequestBody(MemBuf &buf)
either fill buf with available [encoded] request body bytes or return false
Definition: http.cc:2442
Http::StateFlags flags
Definition: http.h:67
Answers make(const Answers ans, const char *why)
stores the corresponding decision
Definition: http.cc:2642
String * upgradeHeaderOut
Upgrade header value sent to the origin server or cache peer.
Definition: http.h:74
void checkDateSkew(HttpReply *)
Definition: http.cc:651
int64_t payloadTruncated
positive when we read more than we wanted
Definition: http.h:155
virtual void abortAll(const char *reason)
abnormal transaction termination; reason is for debugging only
Definition: http.cc:2631
const Http::StatusCode statusCode
HTTP status for debugging.
Definition: http.h:41
virtual bool mayReadVirginReplyBody() const
whether we may receive more virgin response body bytes
Definition: http.cc:1598
bool surrogateNoStore
Definition: http.h:71
int lastChunk
Definition: http.h:66
bool finishingBrokenPost()
if broken posts are enabled for the request, try to fix and return true
Definition: http.cc:2503
CachePeer * _peer
Definition: http.h:64
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
Definition: SBuf.h:86
mb_size_t buildRequestPrefix(MemBuf *mb)
Definition: http.cc:2311
ConnectionStatus statusIfComplete() const
Definition: http.cc:1116
AsyncCall::Pointer closeHandler
Definition: http.h:91
ConnectionStatus
Definition: http.h:92
HttpStateData(FwdState *)
Definition: http.cc:87
const char * blockSwitchingProtocols(const HttpReply &) const
Definition: http.cc:869
bool sendRequest()
Definition: http.cc:2355
void processReplyBody()
Definition: http.cc:1487
Comm::ConnectionPointer serverConnection
Definition: http.h:90
StatusCode
Definition: StatusCode.h:20
void keepaliveAccounting(HttpReply *)
Definition: http.cc:631
bool decodeAndWriteReplyBody()
Definition: http.cc:1455
void readReply(const CommIoCbParams &io)
Definition: http.cc:1219
static bool decideIfWeDoRanges(HttpRequest *orig_request)
Definition: http.cc:2281
@ COMPLETE_NONPERSISTENT_MSG
Definition: http.h:95
void sendComplete()
successfully wrote the entire request (including body, last-chunk, etc.)
Definition: http.cc:1707
void httpStart(FwdState *)
Definition: http.cc:2476
void processReplyHeader()
Definition: http.cc:668
ReuseDecision(const StoreEntry *e, const Http::StatusCode code)
Definition: http.cc:2638
@ COMPLETE_PERSISTENT_MSG
Definition: http.h:94
SBuf inBuf
I/O buffer for receiving server responses.
Definition: http.h:69
virtual void handleMoreRequestBodyAvailable()
Definition: http.cc:2571
void handle1xx(HttpReply *msg)
ignore or start forwarding the 1xx response (a.k.a., control message)
Definition: http.cc:792
SBuf httpMakeVaryMark(HttpRequest *request, HttpReply const *reply)
Definition: http.cc:612
Definition: MemBuf.h:23
const StoreEntry * entry
entry for debugging
Definition: http.h:40
void doneSendingRequestBody()
Definition: http.cc:2555
unsigned char code
Definition: html_quote.c:20
virtual void handleRequestBodyProducerAborted()
Definition: http.cc:2603
void proceedAfter1xx()
restores state and resumes processing after 1xx is ignored or forwarded
Definition: http.cc:896
ConnectionStatus persistentConnStatus() const
Definition: http.cc:1161
@ INCOMPLETE_MSG
Definition: http.h:93
void httpTimeout(const CommTimeoutCbParams &params)
Definition: http.cc:161
Answers answer
the decision id
Definition: http.h:38
virtual bool doneWithServer() const
Definition: http.cc:1739
void abortTransaction(const char *reason)
Definition: http.h:113
void writeReplyBody()
Definition: http.cc:1445
void httpStateConnClosed(const CommCloseCbParams &params)
Definition: http.cc:153
virtual const Comm::ConnectionPointer & dataConnection() const
Definition: http.cc:147
std::ostream & operator<<(std::ostream &os, const HttpStateData::ReuseDecision &d)
Definition: http.cc:2649
ReuseDecision::Answers reusableReply(ReuseDecision &decision)
Definition: http.cc:321
Http1::TeChunkedParser * httpChunkDecoder
Definition: http.h:150
void wroteLast(const CommIoCbParams &io)
called after writing the very last request byte (body, last-chunk, etc)
Definition: http.cc:1670
Http1::ResponseParserPointer hp
Parser being used at present to parse the HTTP/ICY server response.
Definition: http.h:149
assists in making and relaying entry caching/sharing decision
Definition: http.h:29
const char * reason
the decision reason
Definition: http.h:39
int httpCachable(const HttpRequestMethod &)
int eof
Definition: http.h:65
bool sawDateGoBack
Definition: http.h:159
bool peerSupportsConnectionPinning() const
Definition: http.cc:925
virtual void maybeReadVirginBody()
read response data from the network
Definition: http.cc:1607
void processReply()
Definition: http.cc:1317
bool finishingChunkedRequest()
if needed, write last-chunk to end the request body and return true
Definition: http.cc:2538
virtual void start()
called by AsyncStart; do not call directly
Definition: http.cc:2483
ssize_t mb_size_t
Definition: MemBuf.h:17
static void httpBuildRequestHeader(HttpRequest *request, StoreEntry *entry, const AccessLogEntryPointer &al, HttpHeader *hdr_out, const Http::StateFlags &flags)
Definition: http.cc:1859
virtual void sentRequestBody(const CommIoCbParams &io)
Definition: http.cc:2622
size_t read_sz
Definition: http.h:68
void processSurrogateControl(HttpReply *)
Definition: http.cc:283
int64_t payloadSeen
amount of message payload/body received so far.
Definition: http.h:153
bool continueAfterParsingHeader()
Definition: http.cc:1347
virtual void closeServer()
Definition: http.cc:1726
void requestBodyHandler(MemBuf &)
void forwardUpgrade(HttpHeader &)
Definition: http.cc:2041
HttpRequestPointer request
Definition: Client.h:166
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
void const char * buf
Definition: stub_helper.cc:16
~HttpStateData()
Definition: http.cc:130

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors