| 55 | } |
| 56 | |
| 57 | bool |
| 58 | HttpParser::parse(io::IO &io) |
| 59 | { |
| 60 | if (parsed_) { |
| 61 | return true; |
| 62 | } |
| 63 | TSIOBufferBlock block = TSIOBufferReaderStart(io.reader); |
| 64 | while (block != nullptr) { |
| 65 | int64_t size = 0; |
| 66 | const char *const begin = TSIOBufferBlockReadStart(block, io.reader, &size); |
| 67 | const char *iterator = begin; |
| 68 | |
| 69 | parsed_ = (TSHttpHdrParseResp(parser_, buffer_, location_, &iterator, iterator + size) == TS_PARSE_DONE); |
| 70 | TSIOBufferReaderConsume(io.reader, iterator - begin); |
| 71 | |
| 72 | if (parsed_) { |
| 73 | Dbg(dbg_ctl, "HttpParser: response parsing is complete (%u response status code)", statusCode()); |
| 74 | assert(parser_ != nullptr); |
| 75 | destroyParser(); |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | block = TSIOBufferBlockNext(block); |
| 80 | } |
| 81 | return false; |
| 82 | } |
| 83 | |
| 84 | } // namespace ats |
no test coverage detected