Stream.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_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
21
22namespace Http
23{
24
69class Stream : public RefCountable
70{
72
73public:
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
105 void sendBody(StoreIOBuffer bodyData);
108 void noteSentBodyBytes(size_t);
109
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
129public: // 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;
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
159private:
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
#define RefCountable
The locking interface for use on Reference-Counted classes.
Definition: Lock.h:66
int size
Definition: ModDevPoll.cc:75
a transaction problem
Definition: Error.h:18
clientStreamNode * node
Definition: Stream.h:151
StoreIOBuffer queuedBuffer
Definition: Stream.h:153
void sendStartOfMessage(HttpReply *, StoreIOBuffer bodyData)
send an HTTP reply message headers and maybe some initial payload
Definition: Stream.cc:266
void deferRecipientForLater(clientStreamNode *, HttpReply *, StoreIOBuffer receivedData)
Definition: Stream.cc:558
DeferredParams deferredparams
Definition: Stream.h:156
unsigned parsed_ok
Was this parsed correctly?
Definition: Stream.h:137
size_t lengthToSend(Range< int64_t > const &available) const
Definition: Stream.cc:340
MessageBucket::Pointer writeQuotaHandler
response write limiter, if configured
Definition: Stream.h:168
bool canPackMoreRanges() const
Definition: Stream.cc:188
void registerWithConn()
register this stream with the Server
Definition: Stream.cc:52
void packChunk(const StoreIOBuffer &bodyData, MemBuf &)
Definition: Stream.cc:581
void mayUseConnection(bool aBool)
Definition: Stream.h:142
bool connRegistered() const
whether it is registered with a Server
Definition: Stream.h:82
bool connRegistered_
Definition: Stream.h:166
ConnStateData * getConn() const
Definition: Stream.cc:519
clientStream_status_t socketState()
Adapt stream status to account for Range cases.
Definition: Stream.cc:210
void sendBody(StoreIOBuffer bodyData)
send some HTTP reply message payload
Definition: Stream.cc:317
struct Http::Stream::@79 flags
bool mayUseConnection_
Definition: Stream.h:165
MEMPROXY_CLASS(Stream)
void buildRangeHeader(HttpReply *)
add Range headers (if any) to the given HTTP reply message
Definition: Stream.cc:419
char reqbuf[HTTP_REQBUF_SZ]
Definition: Stream.h:134
clientStreamNode * getClientReplyContext() const
Definition: Stream.cc:513
void packRange(StoreIOBuffer const &, MemBuf *)
Definition: Stream.cc:597
int64_t writtenToSocket
Definition: Stream.h:157
void initiateClose(const char *reason)
terminate due to a send/write error (may continue reading)
Definition: Stream.cc:551
void doClose()
Definition: Stream.cc:658
int64_t getNextRangeOffset() const
Definition: Stream.cc:131
bool multipartRangeRequest() const
Definition: Stream.cc:125
Comm::ConnectionPointer clientConnection
details about the client connection socket
Definition: Stream.h:131
HttpReply * reply
Definition: Stream.h:133
bool startOfOutput() const
whether the reply has started being sent
Definition: Stream.cc:61
void noteSentBodyBytes(size_t)
Definition: Stream.cc:363
void finished()
cleanup when the transaction has finished. may destroy 'this'
Definition: Stream.cc:536
void writeComplete(size_t size)
update stream state after a write, may initiate more I/O
Definition: Stream.cc:67
void prepareReply(HttpReply *)
Definition: Stream.cc:569
clientStreamNode * getTail() const
Definition: Stream.cc:504
Stream(const Comm::ConnectionPointer &aConn, ClientHttpRequest *aReq)
construct with HTTP/1.x details
Definition: Stream.cc:23
void noteIoError(const Error &, const LogTagsErrors &)
update state to reflect I/O error
Definition: Stream.cc:527
bool mayUseConnection() const
Definition: Stream.h:140
unsigned deferred
This is a pipelined request waiting for the current object to complete.
Definition: Stream.h:136
void pullData()
get more data to send
Definition: Stream.cc:109
ClientHttpRequest * http
Definition: Stream.h:132
Definition: MemBuf.h:24
Definition: Range.h:19
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:196
clientStream_status_t
Definition: enums.h:125
#define HTTP_REQBUF_SZ
Definition: forward.h:14
Definition: forward.h:22

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors