Stream.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 int xerrno);
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 
clientStreamNode * getTail() const
Definition: Stream.cc:538
void sendBody(StoreIOBuffer bodyData)
send some HTTP reply message payload
Definition: Stream.cc:316
#define HTTP_REQBUF_SZ
Definition: defines.h:216
bool mayUseConnection() const
Definition: Stream.h:140
void writeComplete(size_t size)
update stream state after a write, may initiate more I/O
Definition: Stream.cc:67
void noteIoError(const int xerrno)
update state to reflect I/O error
Definition: Stream.cc:561
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
void packRange(StoreIOBuffer const &, MemBuf *)
Definition: Stream.cc:631
void deferRecipientForLater(clientStreamNode *, HttpReply *, StoreIOBuffer receivedData)
Definition: Stream.cc:592
clientStream_status_t socketState()
Adapt stream status to account for Range cases.
Definition: Stream.cc:213
size_t lengthToSend(Range< int64_t > const &available) const
Definition: Stream.cc:339
int64_t writtenToSocket
Definition: Stream.h:157
void sendStartOfMessage(HttpReply *, StoreIOBuffer bodyData)
send an HTTP reply message headers and maybe some initial payload
Definition: Stream.cc:265
Definition: Range.h:18
void doClose()
Definition: Stream.cc:693
void registerWithConn()
register this stream with the Server
Definition: Stream.cc:52
clientStreamNode * getClientReplyContext() const
Definition: Stream.cc:547
DeferredParams deferredparams
Definition: Stream.h:156
void finished()
cleanup when the transaction has finished. may destroy &#39;this&#39;
Definition: Stream.cc:571
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:124
StoreIOBuffer queuedBuffer
Definition: Stream.h:153
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:615
ClientHttpRequest * http
Definition: Stream.h:132
int64_t getNextRangeOffset() const
Definition: Stream.cc:135
bool connRegistered_
Definition: Stream.h:166
struct Http::Stream::@80 flags
unsigned deferred
This is a pipelined request waiting for the current object to complete.
Definition: Stream.h:136
clientStream_status_t
Definition: enums.h:117
void buildRangeHeader(HttpReply *)
add Range headers (if any) to the given HTTP reply message
Definition: Stream.cc:418
bool connRegistered() const
whether it is registered with a Server
Definition: Stream.h:82
ConnStateData * getConn() const
Definition: Stream.cc:553
void initiateClose(const char *reason)
terminate due to a send/write error (may continue reading)
Definition: Stream.cc:585
clientStreamNode * node
Definition: Stream.h:151
void prepareReply(HttpReply *)
Definition: Stream.cc:603
bool startOfOutput() const
whether the reply has started being sent
Definition: Stream.cc:61
MEMPROXY_CLASS(Stream)
Definition: MemBuf.h:23
Comm::ConnectionPointer clientConnection
details about the client connection socket
Definition: Stream.h:131
bool canPackMoreRanges() const
Definition: Stream.cc:191
bool mayUseConnection_
Definition: Stream.h:165
bool multipartRangeRequest() const
Definition: Stream.cc:129
void pullData()
get more data to send
Definition: Stream.cc:113
HttpReply * reply
Definition: Stream.h:133
int size
Definition: ModDevPoll.cc:77
unsigned parsed_ok
Was this parsed correctly?
Definition: Stream.h:137
void noteSentBodyBytes(size_t)
Definition: Stream.cc:362

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors