| 44 | -------------------------------------------------------------------------*/ |
| 45 | |
| 46 | ParseResult |
| 47 | HTTPHdr::parse_req(HTTPParser *parser, IOBufferReader *r, int *bytes_used, bool eof, int strict_uri_parsing, |
| 48 | size_t max_request_line_size, size_t max_hdr_field_size) |
| 49 | { |
| 50 | const char *start; |
| 51 | const char *tmp; |
| 52 | const char *end; |
| 53 | int used; |
| 54 | |
| 55 | ink_assert(valid()); |
| 56 | ink_assert(m_http->m_polarity == HTTP_TYPE_REQUEST); |
| 57 | |
| 58 | ParseResult state = PARSE_RESULT_CONT; |
| 59 | *bytes_used = 0; |
| 60 | |
| 61 | do { |
| 62 | int64_t b_avail = r->block_read_avail(); |
| 63 | |
| 64 | if (b_avail <= 0 && eof == false) { |
| 65 | break; |
| 66 | } |
| 67 | |
| 68 | tmp = start = r->start(); |
| 69 | end = start + b_avail; |
| 70 | |
| 71 | int heap_slot = m_heap->attach_block(r->get_current_block(), start); |
| 72 | |
| 73 | m_heap->lock_ronly_str_heap(heap_slot); |
| 74 | state = http_parser_parse_req(parser, m_heap, m_http, &tmp, end, false, eof, strict_uri_parsing, max_request_line_size, |
| 75 | max_hdr_field_size); |
| 76 | m_heap->set_ronly_str_heap_end(heap_slot, tmp); |
| 77 | m_heap->unlock_ronly_str_heap(heap_slot); |
| 78 | |
| 79 | used = static_cast<int>(tmp - start); |
| 80 | r->consume(used); |
| 81 | *bytes_used += used; |
| 82 | |
| 83 | } while (state == PARSE_RESULT_CONT); |
| 84 | |
| 85 | return state; |
| 86 | } |
| 87 | |
| 88 | ParseResult |
| 89 | HTTPHdr::parse_resp(HTTPParser *parser, IOBufferReader *r, int *bytes_used, bool eof) |