MCPcopy Create free account
hub / github.com/apache/brpc / DecodeString

Function DecodeString

src/brpc/details/hpack.cpp:606–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

604}
605
606inline ssize_t DecodeString(butil::IOBufBytesIterator& iter, std::string* out) {
607 if (iter == NULL) {
608 return 0;
609 }
610 const bool huffman = *iter & 0x80;
611 uint32_t length = 0;
612 ssize_t in_bytes = DecodeInteger(iter, 7, &length);
613 if (in_bytes <= 0) {
614 return -1;
615 }
616 if (length > iter.bytes_left()) {
617 return 0;
618 }
619 in_bytes += length;
620 out->clear();
621 if (!huffman) {
622 iter.copy_and_forward(out, length);
623 return in_bytes;
624 }
625 HuffmanDecoder d(out, s_huffman_tree);
626 for (; iter != NULL && length; ++iter, --length) {
627 if (d.Decode(*iter) != 0) {
628 return -1;
629 }
630 }
631 if (d.EndStream() != 0) {
632 return -1;
633 }
634 return in_bytes;
635}
636
637HPacker::HPacker()
638 : _encode_table(NULL)

Callers 1

DecodeWithKnownPrefixMethod · 0.85

Calls 6

DecodeIntegerFunction · 0.85
bytes_leftMethod · 0.80
copy_and_forwardMethod · 0.80
clearMethod · 0.45
DecodeMethod · 0.45
EndStreamMethod · 0.45

Tested by

no test coverage detected