| 35 | } |
| 36 | |
| 37 | bool |
| 38 | HttpParser::parse(io::IO &io) |
| 39 | { |
| 40 | using multiplexer_ns::dbg_ctl; |
| 41 | if (parsed_) { |
| 42 | return true; |
| 43 | } |
| 44 | TSIOBufferBlock block = TSIOBufferReaderStart(io.reader); |
| 45 | while (block != nullptr) { |
| 46 | int64_t size = 0; |
| 47 | const char *const begin = TSIOBufferBlockReadStart(block, io.reader, &size); |
| 48 | const char *iterator = begin; |
| 49 | |
| 50 | parsed_ = (TSHttpHdrParseResp(parser_, buffer_, location_, &iterator, iterator + size) == TS_PARSE_DONE); |
| 51 | TSIOBufferReaderConsume(io.reader, iterator - begin); |
| 52 | |
| 53 | if (parsed_) { |
| 54 | Dbg(dbg_ctl, "HttpParser: response parsing is complete (%u response status code)", statusCode()); |
| 55 | assert(parser_ != nullptr); |
| 56 | destroyParser(); |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | block = TSIOBufferBlockNext(block); |
| 61 | } |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | } // namespace ats |
no test coverage detected