Stream.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 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_SRC_HTTP_STREAM_H
10 #define SQUID_SRC_HTTP_STREAM_H
11 
12 #include "http/forward.h"
13 #include "mem/forward.h"
14 #include "StoreIOBuffer.h"
15 #if USE_DELAY_POOLS
16 #include "MessageBucket.h"
17 #endif
18 
19 class clientStreamNode;
20 class ClientHttpRequest;
21 
22 namespace Http
23 {
24 
69 class Stream : public RefCountable
70 {
72 
73 public:
76  ~Stream();
77 
79  void registerWithConn();
80 
82  bool connRegistered() const {return connRegistered_;};
83 
85  bool startOfOutput() const;
86 
88  void writeComplete(size_t size);
89 
91  void pullData();
92 
94  bool multipartRangeRequest() const;
95 
96  int64_t getNextRangeOffset() const;
97  bool canPackMoreRanges() const;
98  size_t lengthToSend(Range<int64_t> const &available) const;
99 
101 
103  void sendStartOfMessage(HttpReply *, StoreIOBuffer bodyData);
105  void sendBody(StoreIOBuffer bodyData);
108  void noteSentBodyBytes(size_t);
109 
111  void buildRangeHeader(HttpReply *);
112 
113  clientStreamNode * getTail() const;
115 
116  ConnStateData *getConn() const;
117 
119  void noteIoError(const Error &, const LogTagsErrors &);
120 
122  void finished();
123 
125  void initiateClose(const char *reason);
126 
128 
129 public: // HTTP/1.x state data
130 
132  ClientHttpRequest *http; /* we pretend to own that Job */
135  struct {
136  unsigned deferred:1;
137  unsigned parsed_ok:1;
138  } flags;
139 
140  bool mayUseConnection() const {return mayUseConnection_;}
141 
142  void mayUseConnection(bool aBool) {
143  mayUseConnection_ = aBool;
144  debugs(33, 3, "This " << this << " marked " << aBool);
145  }
146 
148  {
149 
150  public:
154  };
155 
158 
159 private:
160  void prepareReply(HttpReply *);
161  void packChunk(const StoreIOBuffer &bodyData, MemBuf &);
162  void packRange(StoreIOBuffer const &, MemBuf *);
163  void doClose();
164 
165  bool mayUseConnection_; /* This request may use the connection. Don't read anymore requests for now */
167 #if USE_DELAY_POOLS
169 #endif
170 };
171 
172 } // namespace Http
173 
174 #endif /* SQUID_SRC_HTTP_STREAM_H */
175 
ConnStateData * getConn() const
Definition: Stream.cc:519
struct Http::Stream::@78 flags
void sendStartOfMessage(HttpReply *, StoreIOBuffer bodyData)
send an HTTP reply message headers and maybe some initial payload
Definition: Stream.cc:266
StoreIOBuffer queuedBuffer
Definition: Stream.h:153
void registerWithConn()
register this stream with the Server
Definition: Stream.cc:52
void buildRangeHeader(HttpReply *)
add Range headers (if any) to the given HTTP reply message
Definition: Stream.cc:419
bool connRegistered() const
whether it is registered with a Server
Definition: Stream.h:82
void finished()
cleanup when the transaction has finished. may destroy 'this'
Definition: Stream.cc:536
void mayUseConnection(bool aBool)
Definition: Stream.h:142
char reqbuf[HTTP_REQBUF_SZ]
Definition: Stream.h:134
MessageBucket::Pointer writeQuotaHandler
response write limiter, if configured
Definition: Stream.h:168
clientStream_status_t socketState()
Adapt stream status to account for Range cases.
Definition: Stream.cc:210
int64_t writtenToSocket
Definition: Stream.h:157
int64_t getNextRangeOffset() const
Definition: Stream.cc:131
Definition: forward.h:22
bool multipartRangeRequest() const
Definition: Stream.cc:125
void writeComplete(size_t size)
update stream state after a write, may initiate more I/O
Definition: Stream.cc:67
a transaction problem
Definition: Error.h:18
void noteIoError(const Error &, const LogTagsErrors &)
update state to reflect I/O error
Definition: Stream.cc:527
Definition: Range.h:19
bool mayUseConnection() const
Definition: Stream.h:140
size_t lengthToSend(Range< int64_t > const &available) const
Definition: Stream.cc:340
bool canPackMoreRanges() const
Definition: Stream.cc:188
int size
Definition: ModDevPoll.cc:77
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
void prepareReply(HttpReply *)
Definition: Stream.cc:569
Definition: MemBuf.h:24
clientStreamNode * getClientReplyContext() const
Definition: Stream.cc:513
Comm::ConnectionPointer clientConnection
details about the client connection socket
Definition: Stream.h:131
Stream(const Comm::ConnectionPointer &aConn, ClientHttpRequest *aReq)
construct with HTTP/1.x details
Definition: Stream.cc:23
void packChunk(const StoreIOBuffer &bodyData, MemBuf &)
Definition: Stream.cc:581
ClientHttpRequest * http
Definition: Stream.h:132
bool mayUseConnection_
Definition: Stream.h:165
clientStreamNode * node
Definition: Stream.h:151
HttpReply * reply
Definition: Stream.h:133
bool connRegistered_
Definition: Stream.h:166
clientStreamNode * getTail() const
Definition: Stream.cc:504
unsigned deferred
This is a pipelined request waiting for the current object to complete.
Definition: Stream.h:136
void doClose()
Definition: Stream.cc:658
unsigned parsed_ok
Was this parsed correctly?
Definition: Stream.h:137
clientStream_status_t
Definition: enums.h:125
bool startOfOutput() const
whether the reply has started being sent
Definition: Stream.cc:61
void pullData()
get more data to send
Definition: Stream.cc:109
MEMPROXY_CLASS(Stream)
void deferRecipientForLater(clientStreamNode *, HttpReply *, StoreIOBuffer receivedData)
Definition: Stream.cc:558
#define HTTP_REQBUF_SZ
Definition: forward.h:14
void packRange(StoreIOBuffer const &, MemBuf *)
Definition: Stream.cc:597
void sendBody(StoreIOBuffer bodyData)
send some HTTP reply message payload
Definition: Stream.cc:317
DeferredParams deferredparams
Definition: Stream.h:156
void noteSentBodyBytes(size_t)
Definition: Stream.cc:363
void initiateClose(const char *reason)
terminate due to a send/write error (may continue reading)
Definition: Stream.cc:551

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors