MCPcopy Create free account
hub / github.com/apache/trafficserver / Handler

Class Handler

plugins/multiplexer/dispatch.cc:141–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141class Handler
142{
143 int64_t length;
144 struct timeval start;
145 std::string response;
146
147public:
148 const std::string url;
149
150 Handler(std::string u) : length(0)
151 {
152 assert(!u.empty());
153 const_cast<std::string &>(url).swap(u);
154 gettimeofday(&start, nullptr);
155 }
156
157 void
158 error()
159 {
160 TSError("[" PLUGIN_TAG "] error when communicating with \"%s\"\n", url.c_str());
161 TSStatIntIncrement(statistics.failures, 1);
162 }
163
164 void
165 timeout()
166 {
167 TSError("[" PLUGIN_TAG "] timeout when communicating with \"%s\"\n", url.c_str());
168 TSStatIntIncrement(statistics.timeouts, 1);
169 }
170
171 void
172 header(const TSMBuffer b, const TSMLoc l)
173 {
174 if (dbg_ctl.on()) {
175 const TSIOBuffer buffer = TSIOBufferCreate();
176 TSHttpHdrPrint(b, l, buffer);
177 std::string buf;
178 read(buffer, buf);
179 Dbg(dbg_ctl, "Response header for \"%s\" was:\n%s", url.c_str(), buf.c_str());
180 TSIOBufferDestroy(buffer);
181 }
182 }
183
184 void
185 data(const TSIOBufferReader r, const int64_t l)
186 {
187 length += l;
188 if (dbg_ctl.on()) {
189 std::string buffer;
190 const uint64_t length = read(r, buffer, l);
191 response += buffer;
192 Dbg(dbg_ctl, "Receiving response chunk \"%s\" of %" PRIu64 " bytes", buffer.c_str(), length);
193 }
194 }
195
196 void
197 done()
198 {

Callers 1

dispatchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected