]>
Commit | Line | Data |
---|---|---|
8e64903f | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 The Squid Software Foundation and contributors |
8e64903f AJ |
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_PIPELINE_H | |
10 | #define SQUID_SRC_PIPELINE_H | |
11 | ||
12 | #include "base/RefCount.h" | |
8d664cb0 | 13 | #include "http/forward.h" |
8e64903f AJ |
14 | |
15 | #include <list> | |
16 | ||
8e64903f | 17 | /** |
1fad8490 | 18 | * A queue of transactions awaiting completion. |
8e64903f | 19 | * |
1fad8490 | 20 | * Transactions in the queue may be fully processed, but not yet delivered, |
8e64903f AJ |
21 | * or only partially processed. |
22 | * | |
23 | * - HTTP/1 pipelined requests can be processed out of order but | |
24 | * responses MUST be written to the client in-order. | |
1fad8490 AJ |
25 | * The front() context is for the response writing transaction. |
26 | * The back context may still be reading a request payload/body. | |
27 | * Other contexts are in deferred I/O state, but may be accumulating | |
28 | * payload/body data to be written later. | |
8e64903f | 29 | * |
1fad8490 | 30 | * - HTTP/2 multiplexed streams can be processed and delivered in any order. |
8e64903f AJ |
31 | * |
32 | * For consistency we treat the pipeline as a FIFO queue in both cases. | |
33 | */ | |
34 | class Pipeline | |
35 | { | |
36 | Pipeline(const Pipeline &) = delete; | |
37 | Pipeline & operator =(const Pipeline &) = delete; | |
38 | ||
39 | public: | |
2c391676 | 40 | Pipeline() : nrequests(0) {} |
8ced7106 | 41 | ~Pipeline() = default; |
8e64903f AJ |
42 | |
43 | /// register a new request context to the pipeline | |
d3dddfb5 | 44 | void add(const Http::StreamPointer &); |
8e64903f AJ |
45 | |
46 | /// get the first request context in the pipeline | |
d3dddfb5 | 47 | Http::StreamPointer front() const; |
8e64903f | 48 | |
da6dbcd1 EB |
49 | /// get the last request context in the pipeline |
50 | Http::StreamPointer back() const; | |
51 | ||
8e64903f | 52 | /// how many requests are currently pipelined |
2c391676 | 53 | size_t count() const {return requests.size();} |
8e64903f AJ |
54 | |
55 | /// whether there are none or any requests currently pipelined | |
56 | bool empty() const {return requests.empty();} | |
57 | ||
2c391676 | 58 | /// deregister the front request from the pipeline |
d3dddfb5 | 59 | void popMe(const Http::StreamPointer &); |
8e64903f AJ |
60 | |
61 | /// Number of requests seen in this pipeline (so far). | |
62 | /// Includes incomplete transactions. | |
63 | uint32_t nrequests; | |
64 | ||
65 | private: | |
66 | /// requests parsed from the connection but not yet completed. | |
d3dddfb5 | 67 | std::list<Http::StreamPointer> requests; |
8e64903f AJ |
68 | }; |
69 | ||
70 | #endif /* SQUID_SRC_PIPELINE_H */ | |
71 |