Squid Web Cache master
Loading...
Searching...
No Matches
Stream.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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 "clientStreamForward.h"
13#include "comm/forward.h"
14#include "debug/Stream.h"
15#include "error/Error.h"
16#include "http/forward.h"
17#include "log/forward.h"
18#include "mem/forward.h"
19#include "servers/forward.h"
20#include "StoreIOBuffer.h"
21#if USE_DELAY_POOLS
22#include "MessageBucket.h"
23#endif
24
25namespace Http
26{
27
72class Stream : public RefCountable
73{
75
76public:
79 ~Stream() override;
80
82 void registerWithConn();
83
85 bool connRegistered() const {return connRegistered_;};
86
88 bool startOfOutput() const;
89
91 void writeComplete(size_t size);
92
94 void pullData();
95
97 bool multipartRangeRequest() const;
98
99 int64_t getNextRangeOffset() const;
100 bool canPackMoreRanges() const;
101 size_t lengthToSend(Range<int64_t> const &available) const;
102
104
108 void sendBody(StoreIOBuffer bodyData);
111 void noteSentBodyBytes(size_t);
112
115
116 clientStreamNode * getTail() const;
118
119 ConnStateData *getConn() const;
120
122 void noteIoError(const Error &, const LogTagsErrors &);
123
125 void finished();
126
128 void initiateClose(const char *reason);
129
131
132public: // HTTP/1.x state data
133
135 ClientHttpRequest *http; /* we pretend to own that Job */
138 struct {
139 unsigned deferred:1;
140 unsigned parsed_ok:1;
142
143 bool mayUseConnection() const {return mayUseConnection_;}
144
145 void mayUseConnection(bool aBool) {
146 mayUseConnection_ = aBool;
147 debugs(33, 3, "This " << this << " marked " << aBool);
148 }
149
158
161
162private:
163 void prepareReply(HttpReply *);
164 void packChunk(const StoreIOBuffer &bodyData, MemBuf &);
165 void packRange(StoreIOBuffer const &, MemBuf *);
166 void doClose();
167
168 bool mayUseConnection_; /* This request may use the connection. Don't read anymore requests for now */
170#if USE_DELAY_POOLS
172#endif
173};
174
175} // namespace Http
176
177#endif /* SQUID_SRC_HTTP_STREAM_H */
178
#define RefCountable
The locking interface for use on Reference-Counted classes.
Definition Lock.h:66
int size
Definition ModDevPoll.cc:70
a transaction problem
Definition Error.h:27
clientStreamNode * node
Definition Stream.h:154
StoreIOBuffer queuedBuffer
Definition Stream.h:156
void sendStartOfMessage(HttpReply *, StoreIOBuffer bodyData)
send an HTTP reply message headers and maybe some initial payload
Definition Stream.cc:267
void deferRecipientForLater(clientStreamNode *, HttpReply *, StoreIOBuffer receivedData)
Definition Stream.cc:556
DeferredParams deferredparams
Definition Stream.h:159
unsigned parsed_ok
Was this parsed correctly?
Definition Stream.h:140
size_t lengthToSend(Range< int64_t > const &available) const
Definition Stream.cc:338
MessageBucket::Pointer writeQuotaHandler
response write limiter, if configured
Definition Stream.h:171
bool canPackMoreRanges() const
Definition Stream.cc:189
~Stream() override
Definition Stream.cc:40
void registerWithConn()
register this stream with the Server
Definition Stream.cc:53
void packChunk(const StoreIOBuffer &bodyData, MemBuf &)
Definition Stream.cc:579
void mayUseConnection(bool aBool)
Definition Stream.h:145
struct Http::Stream::@58 flags
bool connRegistered() const
whether it is registered with a Server
Definition Stream.h:85
bool connRegistered_
Definition Stream.h:169
ConnStateData * getConn() const
Definition Stream.cc:517
clientStream_status_t socketState()
Adapt stream status to account for Range cases.
Definition Stream.cc:211
void sendBody(StoreIOBuffer bodyData)
send some HTTP reply message payload
Definition Stream.cc:315
bool mayUseConnection_
Definition Stream.h:168
MEMPROXY_CLASS(Stream)
void buildRangeHeader(HttpReply *)
add Range headers (if any) to the given HTTP reply message
Definition Stream.cc:417
char reqbuf[HTTP_REQBUF_SZ]
Definition Stream.h:137
clientStreamNode * getClientReplyContext() const
Definition Stream.cc:511
void packRange(StoreIOBuffer const &, MemBuf *)
Definition Stream.cc:595
int64_t writtenToSocket
Definition Stream.h:160
void initiateClose(const char *reason)
terminate due to a send/write error (may continue reading)
Definition Stream.cc:549
void doClose()
Definition Stream.cc:656
int64_t getNextRangeOffset() const
Definition Stream.cc:132
bool multipartRangeRequest() const
Definition Stream.cc:126
Comm::ConnectionPointer clientConnection
details about the client connection socket
Definition Stream.h:134
HttpReply * reply
Definition Stream.h:136
bool startOfOutput() const
whether the reply has started being sent
Definition Stream.cc:62
void noteSentBodyBytes(size_t)
Definition Stream.cc:361
void finished()
cleanup when the transaction has finished. may destroy 'this'
Definition Stream.cc:534
void writeComplete(size_t size)
update stream state after a write, may initiate more I/O
Definition Stream.cc:68
void prepareReply(HttpReply *)
Definition Stream.cc:567
clientStreamNode * getTail() const
Definition Stream.cc:502
void noteIoError(const Error &, const LogTagsErrors &)
update state to reflect I/O error
Definition Stream.cc:525
bool mayUseConnection() const
Definition Stream.h:143
unsigned deferred
This is a pipelined request waiting for the current object to complete.
Definition Stream.h:139
void pullData()
get more data to send
Definition Stream.cc:110
ClientHttpRequest * http
Definition Stream.h:135
Definition Range.h:19
#define debugs(SECTION, LEVEL, CONTENT)
Definition Stream.h:192
clientStream_status_t
Definition enums.h:120
#define HTTP_REQBUF_SZ
Definition forward.h:14
Definition forward.h:18