| 731 | } |
| 732 | |
| 733 | inline ssize_t HPacker::DecodeWithKnownPrefix( |
| 734 | butil::IOBufBytesIterator& iter, Header* h, uint8_t prefix_size) const { |
| 735 | int index = 0; |
| 736 | ssize_t index_bytes = DecodeInteger(iter, prefix_size, (uint32_t*)&index); |
| 737 | ssize_t name_bytes = 0; |
| 738 | if (index_bytes <= 0) { |
| 739 | LOG(ERROR) << "Fail to decode index"; |
| 740 | return -1; |
| 741 | } |
| 742 | if (index != 0) { |
| 743 | const Header* indexed_header = HeaderAt(index); |
| 744 | if (indexed_header == NULL) { |
| 745 | LOG(ERROR) << "No header at index=" << index; |
| 746 | return -1; |
| 747 | } |
| 748 | h->name = indexed_header->name; |
| 749 | } else { |
| 750 | name_bytes = DecodeString(iter, &h->name); |
| 751 | if (name_bytes <= 0) { |
| 752 | LOG(ERROR) << "Fail to decode name"; |
| 753 | return -1; |
| 754 | } |
| 755 | tolower(&h->name); |
| 756 | } |
| 757 | ssize_t value_bytes = DecodeString(iter, &h->value); |
| 758 | if (value_bytes <= 0) { |
| 759 | LOG(ERROR) << "Fail to decode value"; |
| 760 | return -1; |
| 761 | } |
| 762 | return index_bytes + name_bytes + value_bytes; |
| 763 | } |
| 764 | |
| 765 | ssize_t HPacker::Decode(butil::IOBufBytesIterator& iter, Header* h) { |
| 766 | if (iter == NULL) { |
nothing calls this directly
no test coverage detected