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

Method populateFrom

plugins/slice/HttpHeader.cc:325–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323/////// HdrMgr
324
325TSParseResult
326HdrMgr::populateFrom(TSHttpParser const http_parser, TSIOBufferReader const reader, HeaderParseFunc const parsefunc,
327 int64_t *const bytes)
328{
329 TSParseResult parse_res = TS_PARSE_CONT;
330
331 if (nullptr == m_buffer) {
332 m_buffer = TSMBufferCreate();
333 }
334 if (nullptr == m_lochdr) {
335 m_lochdr = TSHttpHdrCreate(m_buffer);
336 }
337
338 int64_t avail = TSIOBufferReaderAvail(reader);
339 if (0 < avail) {
340 TSIOBufferBlock block = TSIOBufferReaderStart(reader);
341 int64_t consumed = 0;
342
343 parse_res = TS_PARSE_CONT;
344
345 while (nullptr != block && 0 < avail) {
346 int64_t blockbytes = 0;
347 char const *const bstart = TSIOBufferBlockReadStart(block, reader, &blockbytes);
348
349 char const *ptr = bstart;
350 char const *endptr = ptr + blockbytes;
351
352 parse_res = parsefunc(http_parser, m_buffer, m_lochdr, &ptr, endptr);
353
354 int64_t const bytes_parsed(ptr - bstart);
355
356 consumed += bytes_parsed;
357 avail -= bytes_parsed;
358
359 if (TS_PARSE_CONT == parse_res) {
360 block = TSIOBufferBlockNext(block);
361 } else {
362 break;
363 }
364 }
365 TSIOBufferReaderConsume(reader, consumed);
366
367 if (nullptr != bytes) {
368 *bytes = consumed;
369 }
370 } else if (nullptr != bytes) {
371 *bytes = 0;
372 }
373
374 return parse_res;
375}

Callers 4

handle_server_respFunction · 0.45
handle_client_reqFunction · 0.45
read_requestFunction · 0.45
read_resp_hdrFunction · 0.45

Calls 7

TSMBufferCreateFunction · 0.85
TSHttpHdrCreateFunction · 0.85
TSIOBufferReaderAvailFunction · 0.85
TSIOBufferReaderStartFunction · 0.50
TSIOBufferBlockReadStartFunction · 0.50
TSIOBufferBlockNextFunction · 0.50
TSIOBufferReaderConsumeFunction · 0.50

Tested by

no test coverage detected