http.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
21 class HttpStateData : public Client
22 {
24 
25 public:
26 
29  {
30  public:
32 
35  Answers make(const Answers ans, const char *why);
36 
38  const char *reason;
39  const StoreEntry *entry;
41  };
42 
45 
47  StoreEntry * entry,
48  const AccessLogEntryPointer &al,
49  HttpHeader * hdr_out,
50  const Http::StateFlags &flags);
51 
52  virtual const Comm::ConnectionPointer & dataConnection() const;
53  /* should be private */
54  bool sendRequest();
55  void processReplyHeader();
56  void processReplyBody();
57  void readReply(const CommIoCbParams &io);
58  virtual void maybeReadVirginBody(); // read response data from the network
59 
60  // Checks whether the response is cacheable/shareable.
62 
63  CachePeer *_peer; /* CachePeer request made to */
64  int eof; /* reached end-of-object? */
65  int lastChunk; /* reached last chunk of a chunk-encoded reply */
67  size_t read_sz;
71 
73 
74 protected:
75  void processReply();
76  void proceedAfter1xx();
77  void handle1xx(HttpReply *msg);
78 
79 private:
91  };
95  void checkDateSkew(HttpReply *);
96 
98  void truncateVirginBody();
99 
100  virtual void start();
101  virtual void haveParsedReplyHeaders();
102  virtual bool getMoreRequestBody(MemBuf &buf);
103  virtual void closeServer(); // end communication with the server
104  virtual bool doneWithServer() const; // did we end communication?
105  virtual void abortAll(const char *reason); // abnormal termination
106  virtual bool mayReadVirginReplyBody() const;
107 
108  void abortTransaction(const char *reason) { abortAll(reason); } // abnormal termination
109 
119  bool maybeMakeSpaceAvailable(bool grow);
120 
121  // consuming request body
122  virtual void handleMoreRequestBodyAvailable();
123  virtual void handleRequestBodyProducerAborted();
124 
125  void writeReplyBody();
127  bool finishingBrokenPost();
129  void doneSendingRequestBody();
130  void requestBodyHandler(MemBuf &);
131  virtual void sentRequestBody(const CommIoCbParams &io);
132  void wroteLast(const CommIoCbParams &io);
133  void sendComplete();
134  void httpStateConnClosed(const CommCloseCbParams &params);
135  void httpTimeout(const CommTimeoutCbParams &params);
136 
138  static bool decideIfWeDoRanges (HttpRequest * orig_request);
139  bool peerSupportsConnectionPinning() const;
140 
144 
146  int64_t payloadSeen;
149 
153 };
154 
155 std::ostream &operator <<(std::ostream &os, const HttpStateData::ReuseDecision &d);
156 
157 int httpCachable(const HttpRequestMethod&);
158 void httpStart(FwdState *);
160 
161 #endif /* SQUID_HTTP_H */
162 
virtual void haveParsedReplyHeaders()
called when we have final (possibly adapted) reply headers; kids extend
Definition: http.cc:895
assists in making and relaying entry caching/sharing decision
Definition: http.h:28
bool continueAfterParsingHeader()
Definition: http.cc:1250
bool peerSupportsConnectionPinning() const
Definition: http.cc:841
bool finishingChunkedRequest()
if needed, write last-chunk to end the request body and return true
Definition: http.cc:2352
void processReply()
Definition: http.cc:1220
virtual const Comm::ConnectionPointer & dataConnection() const
Definition: http.cc:141
virtual void sentRequestBody(const CommIoCbParams &io)
Definition: http.cc:2436
int64_t payloadSeen
amount of message payload/body received so far.
Definition: http.h:146
Definition: SBuf.h:87
virtual bool mayReadVirginReplyBody() const
whether we may receive more virgin response body bytes
Definition: http.cc:1495
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
StoreEntry * entry
Definition: Client.h:164
Definition: Client.h:29
ReuseDecision(const StoreEntry *e, const Http::StatusCode code)
Definition: http.cc:2452
virtual void abortAll(const char *reason)
abnormal transaction termination; reason is for debugging only
Definition: http.cc:2445
static void httpBuildRequestHeader(HttpRequest *request, StoreEntry *entry, const AccessLogEntryPointer &al, HttpHeader *hdr_out, const Http::StateFlags &flags)
Definition: http.cc:1747
void writeReplyBody()
Definition: http.cc:1345
const StoreEntry * entry
entry for debugging
Definition: http.h:39
CachePeer * _peer
Definition: http.h:63
AsyncCall::Pointer closeHandler
Definition: http.h:86
void handle1xx(HttpReply *msg)
ignore or start forwarding the 1xx response (a.k.a., control message)
Definition: http.cc:786
virtual void maybeReadVirginBody()
read response data from the network
Definition: http.cc:1504
StatusCode
Definition: StatusCode.h:20
Http1::TeChunkedParser * httpChunkDecoder
Definition: http.h:143
int eof
Definition: http.h:64
void processSurrogateControl(HttpReply *)
Definition: http.cc:277
virtual bool doneWithServer() const
Definition: http.cc:1636
Http1::ResponseParserPointer hp
Parser being used at present to parse the HTTP/ICY server response.
Definition: http.h:142
void checkDateSkew(HttpReply *)
Definition: http.cc:645
int lastChunk
Definition: http.h:65
void httpStart(FwdState *)
Definition: http.cc:2292
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
ConnectionStatus statusIfComplete() const
Definition: http.cc:1019
void httpStateConnClosed(const CommCloseCbParams &params)
Definition: http.cc:147
bool ignoreCacheControl
Definition: http.h:69
void sendComplete()
successfully wrote the entire request (including body, last-chunk, etc.)
Definition: http.cc:1604
SBuf httpMakeVaryMark(HttpRequest *request, HttpReply const *reply)
Definition: http.cc:606
void httpTimeout(const CommTimeoutCbParams &params)
Definition: http.cc:155
bool surrogateNoStore
Definition: http.h:70
virtual void start()
called by AsyncStart; do not call directly
Definition: http.cc:2299
unsigned char code
Definition: html_quote.c:20
void const char * buf
Definition: stub_helper.cc:16
void keepaliveAccounting(HttpReply *)
Definition: http.cc:625
ConnectionStatus persistentConnStatus() const
Definition: http.cc:1064
SBuf inBuf
I/O buffer for receiving server responses.
Definition: http.h:68
bool sendRequest()
Definition: http.cc:2171
Http::StateFlags flags
Definition: http.h:66
bool sawDateGoBack
Definition: http.h:152
mb_size_t buildRequestPrefix(MemBuf *mb)
Definition: http.cc:2135
Answers answer
the decision id
Definition: http.h:37
void processReplyBody()
Definition: http.cc:1387
HttpRequestPointer request
Definition: Client.h:166
Comm::ConnectionPointer serverConnection
Definition: http.h:85
std::ostream & operator<<(std::ostream &os, const HttpStateData::ReuseDecision &d)
Definition: http.cc:2463
int64_t payloadTruncated
positive when we read more than we wanted
Definition: http.h:148
void processReplyHeader()
Definition: http.cc:662
ssize_t mb_size_t
Definition: MemBuf.h:17
virtual void handleMoreRequestBodyAvailable()
Definition: http.cc:2385
Definition: MemBuf.h:23
void abortTransaction(const char *reason)
Definition: http.h:108
bool decodeAndWriteReplyBody()
Definition: http.cc:1355
virtual void closeServer()
Definition: http.cc:1623
ReuseDecision::Answers reusableReply(ReuseDecision &decision)
Definition: http.cc:315
int httpCachable(const HttpRequestMethod &)
void requestBodyHandler(MemBuf &)
void readReply(const CommIoCbParams &io)
Definition: http.cc:1122
~HttpStateData()
Definition: http.cc:126
ConnectionStatus
Definition: http.h:87
Answers make(const Answers ans, const char *why)
stores the corresponding decision
Definition: http.cc:2456
static bool decideIfWeDoRanges(HttpRequest *orig_request)
Definition: http.cc:2105
void doneSendingRequestBody()
Definition: http.cc:2369
const Http::StatusCode statusCode
HTTP status for debugging.
Definition: http.h:40
bool finishingBrokenPost()
if broken posts are enabled for the request, try to fix and return true
Definition: http.cc:2319
virtual bool getMoreRequestBody(MemBuf &buf)
either fill buf with available [encoded] request body bytes or return false
Definition: http.cc:2258
size_t read_sz
Definition: http.h:67
virtual void handleRequestBodyProducerAborted()
Definition: http.cc:2417
void wroteLast(const CommIoCbParams &io)
called after writing the very last request byte (body, last-chunk, etc)
Definition: http.cc:1567
bool maybeMakeSpaceAvailable(bool grow)
Definition: http.cc:1530
const char * reason
the decision reason
Definition: http.h:38
HttpStateData(FwdState *)
Definition: http.cc:86
void truncateVirginBody()
Definition: http.cc:1317
void proceedAfter1xx()
restores state and resumes processing after 1xx is ignored or forwarded
Definition: http.cc:830

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors