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

Method handle

plugins/multiplexer/fetcher.h:175–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173 }
174
175 static int
176 handle(TSCont c, TSEvent e, void * /* data ATS_UNUSED */)
177 {
178 using multiplexer_ns::dbg_ctl;
179
180 Self *const self = static_cast<Self *const>(TSContDataGet(c));
181 assert(self != NULL);
182 switch (e) {
183 case TS_EVENT_ERROR:
184 Dbg(dbg_ctl, "HttpTransaction: ERROR");
185 self->t_.error();
186 self->abort();
187 close(self);
188 TSContDataSet(c, nullptr);
189 break;
190 case TS_EVENT_VCONN_EOS:
191 Dbg(dbg_ctl, "HttpTransaction: EOS");
192 goto here;
193
194 case TS_EVENT_VCONN_READ_COMPLETE:
195 Dbg(dbg_ctl, "HttpTransaction: Read Complete");
196 goto here;
197
198 case TS_EVENT_VCONN_READ_READY:
199 Dbg(dbg_ctl, "HttpTransaction: Read");
200 here: {
201 assert(self->in_ != NULL);
202 assert(self->in_->reader != NULL);
203 assert(self->in_->vio != NULL);
204 int64_t available = TSIOBufferReaderAvail(self->in_->reader);
205 if (available > 0) {
206 TSVIONDoneSet(self->in_->vio, available + TSVIONDoneGet(self->in_->vio) + 2);
207 if (self->parsingHeaders_) {
208 if (self->parser_.parse(*self->in_)) {
209 if (isChunkEncoding(self->parser_.buffer_, self->parser_.location_)) {
210 assert(self->chunkDecoder_ == NULL);
211 self->chunkDecoder_ = new ChunkDecoder();
212 }
213 self->t_.header(self->parser_.buffer_, self->parser_.location_);
214 self->parsingHeaders_ = false;
215 }
216 // Parsing headers will indirectly read from our reader. Update available accordingly.
217 available = TSIOBufferReaderAvail(self->in_->reader);
218 }
219 if (!self->parsingHeaders_) {
220 if (self->chunkDecoder_ != NULL) {
221 available = self->chunkDecoder_->decode(self->in_->reader);
222 if (available == 0) {
223 self->t_.data(self->in_->reader, available);
224 }
225 while (available > 0) {
226 self->t_.data(self->in_->reader, available);
227 TSIOBufferReaderConsume(self->in_->reader, available);
228 available = self->chunkDecoder_->decode(self->in_->reader);
229 }
230 } else {
231 self->t_.data(self->in_->reader, available);
232 TSIOBufferReaderConsume(self->in_->reader, available);

Callers

nothing calls this directly

Calls 15

abortMethod · 0.95
TSContDataGetFunction · 0.85
TSContDataSetFunction · 0.85
TSIOBufferReaderAvailFunction · 0.85
TSVIONDoneSetFunction · 0.85
TSVIONDoneGetFunction · 0.85
TSVIOReenableFunction · 0.85
TSVConnShutdownFunction · 0.85
TSVIONTodoGetFunction · 0.85
readFunction · 0.70
TSIOBufferReaderConsumeFunction · 0.50
errorMethod · 0.45

Tested by

no test coverage detected