http.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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
18class FwdState;
19class HttpHeader;
20class String;
21
22class HttpStateData : public Client
23{
25
26public:
27
30 {
31 public:
33
36 Answers make(const Answers ans, const char *why);
37
39 const char *reason;
42 };
43
46
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 = nullptr; /* CachePeer request made to */
65 int eof = 0; /* reached end-of-object? */
66 int lastChunk = 0; /* reached last chunk of a chunk-encoded reply */
69 bool ignoreCacheControl = false;
70 bool surrogateNoStore = false;
71
74
76
77protected:
78 /* Client API */
79 virtual void noteDelayAwareReadChance();
80
81 void processReply();
82 void proceedAfter1xx();
83 void handle1xx(HttpReply *msg);
84 void drop1xx(const char *reason);
85
86private:
98 };
102 void checkDateSkew(HttpReply *);
103
105 void truncateVirginBody();
106
107 virtual void start();
108 virtual void haveParsedReplyHeaders();
109 virtual bool getMoreRequestBody(MemBuf &buf);
110 virtual void closeServer(); // end communication with the server
111 virtual bool doneWithServer() const; // did we end communication?
112 virtual void abortAll(const char *reason); // abnormal termination
113 virtual bool mayReadVirginReplyBody() const;
114
115 void abortTransaction(const char *reason) { abortAll(reason); } // abnormal termination
116
126 bool maybeMakeSpaceAvailable(bool grow);
127
128 // consuming request body
129 virtual void handleMoreRequestBodyAvailable();
131
132 void writeReplyBody();
134 bool finishingBrokenPost();
138 virtual void sentRequestBody(const CommIoCbParams &io);
139 void wroteLast(const CommIoCbParams &io);
140 void sendComplete();
141 void httpStateConnClosed(const CommCloseCbParams &params);
142 void httpTimeout(const CommTimeoutCbParams &params);
143
146 static bool decideIfWeDoRanges (HttpRequest * orig_request);
148 const char *blockSwitchingProtocols(const HttpReply&) const;
149
153
155 int64_t payloadSeen = 0;
157 int64_t payloadTruncated = 0;
158
161 bool sawDateGoBack = false;
162};
163
164std::ostream &operator <<(std::ostream &os, const HttpStateData::ReuseDecision &d);
165
167void httpStart(FwdState *);
169
170#endif /* SQUID_HTTP_H */
171
ssize_t mb_size_t
Definition: MemBuf.h:17
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
Definition: Client.h:35
HttpRequestPointer request
Definition: Client.h:178
StoreEntry * entry
Definition: Client.h:176
assists in making and relaying entry caching/sharing decision
Definition: http.h:30
const Http::StatusCode statusCode
HTTP status for debugging.
Definition: http.h:41
Answers answer
the decision id
Definition: http.h:38
ReuseDecision(const StoreEntry *e, const Http::StatusCode code)
Definition: http.cc:2612
const StoreEntry * entry
entry for debugging
Definition: http.h:40
Answers make(const Answers ans, const char *why)
stores the corresponding decision
Definition: http.cc:2616
const char * reason
the decision reason
Definition: http.h:39
void httpStateConnClosed(const CommCloseCbParams &params)
Definition: http.cc:136
AsyncCall::Pointer closeHandler
Definition: http.h:93
Http1::ResponseParserPointer hp
Parser being used at present to parse the HTTP/ICY server response.
Definition: http.h:151
virtual void maybeReadVirginBody()
read response data from the network
Definition: http.cc:1573
String * upgradeHeaderOut
Upgrade header value sent to the origin server or cache peer.
Definition: http.h:73
void doneSendingRequestBody()
Definition: http.cc:2528
void handle1xx(HttpReply *msg)
ignore or start forwarding the 1xx response (a.k.a., control message)
Definition: http.cc:746
virtual void abortAll(const char *reason)
abnormal transaction termination; reason is for debugging only
Definition: http.cc:2605
void processReply()
Definition: http.cc:1271
CachePeer * _peer
Definition: http.h:64
const char * blockSwitchingProtocols(const HttpReply &) const
Definition: http.cc:823
void processReplyBody()
Definition: http.cc:1455
virtual void handleRequestBodyProducerAborted()
Definition: http.cc:2576
static void httpBuildRequestHeader(HttpRequest *request, StoreEntry *entry, const AccessLogEntryPointer &al, HttpHeader *hdr_out, const Http::StateFlags &flags)
Definition: http.cc:1825
virtual bool doneWithServer() const
Definition: http.cc:1705
virtual bool mayReadVirginReplyBody() const
whether we may receive more virgin response body bytes
Definition: http.cc:1564
static bool decideIfWeDoRanges(HttpRequest *orig_request)
Definition: http.cc:2254
void truncateVirginBody()
Definition: http.cc:1372
ConnectionStatus persistentConnStatus() const
Definition: http.cc:1118
void writeReplyBody()
Definition: http.cc:1400
void sendComplete()
successfully wrote the entire request (including body, last-chunk, etc.)
Definition: http.cc:1673
void httpTimeout(const CommTimeoutCbParams &params)
Definition: http.cc:144
ReuseDecision::Answers reusableReply(ReuseDecision &decision)
Definition: http.cc:294
void checkDateSkew(HttpReply *)
Definition: http.cc:626
int64_t payloadTruncated
positive when we read more than we wanted
Definition: http.h:157
int eof
Definition: http.h:65
void requestBodyHandler(MemBuf &)
void abortTransaction(const char *reason)
Definition: http.h:115
mb_size_t buildRequestPrefix(MemBuf *mb)
Definition: http.cc:2284
int lastChunk
Definition: http.h:66
bool sendRequest()
Definition: http.cc:2328
void readReply(const CommIoCbParams &io)
Definition: http.cc:1175
SBuf inBuf
I/O buffer for receiving server responses.
Definition: http.h:68
virtual void start()
called by AsyncStart; do not call directly
Definition: http.cc:2456
bool surrogateNoStore
Definition: http.h:70
HttpStateData(FwdState *)
Definition: http.cc:77
Http::StateFlags flags
Definition: http.h:67
bool ignoreCacheControl
Definition: http.h:69
void processSurrogateControl(HttpReply *)
Definition: http.cc:256
virtual void haveParsedReplyHeaders()
called when we have final (possibly adapted) reply headers; kids extend
Definition: http.cc:937
ConnectionStatus statusIfComplete() const
Definition: http.cc:1067
bool decodeAndWriteReplyBody()
Definition: http.cc:1423
bool continueAfterParsingHeader()
Definition: http.cc:1302
int64_t payloadSeen
amount of message payload/body received so far.
Definition: http.h:155
bool maybeMakeSpaceAvailable(bool grow)
Definition: http.cc:1599
ConnectionStatus
Definition: http.h:94
@ COMPLETE_PERSISTENT_MSG
Definition: http.h:96
@ INCOMPLETE_MSG
Definition: http.h:95
@ COMPLETE_NONPERSISTENT_MSG
Definition: http.h:97
bool peerSupportsConnectionPinning() const
Definition: http.cc:879
virtual void handleMoreRequestBodyAvailable()
Definition: http.cc:2544
bool sawDateGoBack
Definition: http.h:161
void wroteLast(const CommIoCbParams &io)
called after writing the very last request byte (body, last-chunk, etc)
Definition: http.cc:1636
virtual void sentRequestBody(const CommIoCbParams &io)
Definition: http.cc:2596
virtual bool getMoreRequestBody(MemBuf &buf)
either fill buf with available [encoded] request body bytes or return false
Definition: http.cc:2415
void processReplyHeader()
Definition: http.cc:643
~HttpStateData()
Definition: http.cc:113
Comm::ConnectionPointer serverConnection
Definition: http.h:92
void proceedAfter1xx()
restores state and resumes processing after 1xx is ignored or forwarded
Definition: http.cc:850
bool finishingChunkedRequest()
if needed, write last-chunk to end the request body and return true
Definition: http.cc:2511
void forwardUpgrade(HttpHeader &)
Definition: http.cc:2002
virtual void closeServer()
Definition: http.cc:1692
virtual const Comm::ConnectionPointer & dataConnection() const
Definition: http.cc:130
virtual void noteDelayAwareReadChance()
Definition: http.cc:1168
void keepaliveAccounting(HttpReply *)
Definition: http.cc:606
Http1::TeChunkedParser * httpChunkDecoder
Definition: http.h:152
bool finishingBrokenPost()
if broken posts are enabled for the request, try to fix and return true
Definition: http.cc:2476
void drop1xx(const char *reason)
Definition: http.cc:805
Definition: MemBuf.h:24
Definition: SBuf.h:94
unsigned char code
Definition: html_quote.c:20
int httpCachable(const HttpRequestMethod &)
SBuf httpMakeVaryMark(HttpRequest *request, HttpReply const *reply)
Definition: http.cc:587
void httpStart(FwdState *)
Definition: http.cc:2449
std::ostream & operator<<(std::ostream &os, const HttpStateData::ReuseDecision &d)
Definition: http.cc:2623
StatusCode
Definition: StatusCode.h:20
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors