/src/trafficserver/include/proxy/http/Http1ClientSession.h
Line | Count | Source |
1 | | /** @file |
2 | | |
3 | | A brief file description |
4 | | |
5 | | @section license License |
6 | | |
7 | | Licensed to the Apache Software Foundation (ASF) under one |
8 | | or more contributor license agreements. See the NOTICE file |
9 | | distributed with this work for additional information |
10 | | regarding copyright ownership. The ASF licenses this file |
11 | | to you under the Apache License, Version 2.0 (the |
12 | | "License"); you may not use this file except in compliance |
13 | | with the License. You may obtain a copy of the License at |
14 | | |
15 | | http://www.apache.org/licenses/LICENSE-2.0 |
16 | | |
17 | | Unless required by applicable law or agreed to in writing, software |
18 | | distributed under the License is distributed on an "AS IS" BASIS, |
19 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
20 | | See the License for the specific language governing permissions and |
21 | | limitations under the License. |
22 | | */ |
23 | | |
24 | | /**************************************************************************** |
25 | | |
26 | | Http1ClientSession.h |
27 | | |
28 | | Description: |
29 | | |
30 | | ****************************************************************************/ |
31 | | |
32 | | #pragma once |
33 | | |
34 | | #include "api/InkAPIInternal.h" |
35 | | #include "proxy/hdrs/HTTP.h" |
36 | | #include "proxy/http/HttpConfig.h" |
37 | | #include "proxy/IPAllow.h" |
38 | | #include "proxy/ProxySession.h" |
39 | | #include "proxy/http/Http1ClientTransaction.h" |
40 | | |
41 | | #ifdef USE_HTTP_DEBUG_LISTS |
42 | | extern ink_mutex debug_cs_list_mutex; |
43 | | #endif |
44 | | |
45 | | class HttpSM; |
46 | | class Http1ClientSession : public ProxySession |
47 | | { |
48 | | public: |
49 | | using super = ProxySession; ///< Parent type. |
50 | | Http1ClientSession(); |
51 | 0 | ~Http1ClientSession() = default; |
52 | | |
53 | | // Implement ProxySession interface. |
54 | | void new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader) override; |
55 | | void start() override; |
56 | | void release(ProxyTransaction *trans) override; // Indicate we are done with a transaction |
57 | | void release_transaction(); |
58 | | void destroy() override; |
59 | | void free() override; |
60 | | |
61 | | bool attach_server_session(PoolableSession *ssession, bool transaction_done = true) override; |
62 | | |
63 | | // Implement VConnection interface. |
64 | | void do_io_close(int lerrno = -1) override; |
65 | | |
66 | | // Accessor Methods |
67 | | bool allow_half_open() const; |
68 | | void set_half_close_flag(bool flag) override; |
69 | | bool get_half_close_flag() const override; |
70 | | int get_transact_count() const override; |
71 | | bool is_chunked_encoding_supported() const override; |
72 | | virtual bool is_outbound_transparent() const; |
73 | | |
74 | | PoolableSession *get_server_session() const override; |
75 | | const char *get_protocol_string() const override; |
76 | | |
77 | | void increment_current_active_connections_stat() override; |
78 | | void decrement_current_active_connections_stat() override; |
79 | | |
80 | | private: |
81 | | Http1ClientSession(Http1ClientSession &); |
82 | | |
83 | | ProxyTransaction *new_transaction() override; |
84 | | |
85 | | int state_keep_alive(int event, void *data); |
86 | | int state_slave_keep_alive(int event, void *data); |
87 | | int state_wait_for_close(int event, void *data); |
88 | | |
89 | | enum class C_Read_State { |
90 | | INIT, |
91 | | ACTIVE_READER, |
92 | | KEEP_ALIVE, |
93 | | HALF_CLOSED, |
94 | | CLOSED, |
95 | | }; |
96 | | |
97 | | enum class Magic : uint32_t { |
98 | | ALIVE = 0x0123FEED, |
99 | | DEAD = 0xDEADFEED, |
100 | | }; |
101 | | |
102 | | Magic magic = Magic::DEAD; |
103 | | |
104 | | /// A monotonically increasing count of all transactions ever handled by the session. |
105 | | int transact_count = 0; |
106 | | bool half_close = false; |
107 | | bool conn_decrease = false; |
108 | | |
109 | | MIOBuffer *read_buffer = nullptr; |
110 | | IOBufferReader *_reader = nullptr; |
111 | | |
112 | | C_Read_State read_state = C_Read_State::INIT; |
113 | | |
114 | | VIO *ka_vio = nullptr; |
115 | | VIO *slave_ka_vio = nullptr; |
116 | | |
117 | | PoolableSession *bound_ss = nullptr; |
118 | | |
119 | | int released_transactions = 0; |
120 | | |
121 | | int64_t read_from_early_data = 0; |
122 | | |
123 | | public: |
124 | | // Link<Http1ClientSession> debug_link; |
125 | | LINK(Http1ClientSession, debug_link); |
126 | | |
127 | | /// Set outbound connection to transparent. |
128 | | bool f_outbound_transparent = false; |
129 | | |
130 | | Http1ClientTransaction trans; |
131 | | }; |
132 | | |
133 | | extern ClassAllocator<Http1ClientSession> http1ClientSessionAllocator; |