MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / read_content

Function read_content

examples/server/httplib.h:3651–3678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3649
3650template <typename T>
3651bool read_content(Stream &strm, T &x, size_t payload_max_length, int &status,
3652 Progress progress, ContentReceiverWithProgress receiver,
3653 bool decompress) {
3654 return prepare_content_receiver(
3655 x, status, std::move(receiver), decompress,
3656 [&](const ContentReceiverWithProgress &out) {
3657 auto ret = true;
3658 auto exceed_payload_max_length = false;
3659
3660 if (is_chunked_transfer_encoding(x.headers)) {
3661 ret = read_content_chunked(strm, x, out);
3662 } else if (!has_header(x.headers, "Content-Length")) {
3663 ret = read_content_without_length(strm, out);
3664 } else {
3665 auto len = get_header_value<uint64_t>(x.headers, "Content-Length");
3666 if (len > payload_max_length) {
3667 exceed_payload_max_length = true;
3668 skip_content_with_length(strm, len);
3669 ret = false;
3670 } else if (len > 0) {
3671 ret = read_content_with_length(strm, len, std::move(progress), out);
3672 }
3673 }
3674
3675 if (!ret) { status = exceed_payload_max_length ? 413 : 400; }
3676 return ret;
3677 });
3678} // namespace detail
3679
3680inline ssize_t write_headers(Stream &strm, const Headers &headers) {
3681 ssize_t write_len = 0;

Callers 3

read_content_coreMethod · 0.85
routingMethod · 0.85
process_requestMethod · 0.85

Calls 7

prepare_content_receiverFunction · 0.85
read_content_chunkedFunction · 0.85
has_headerFunction · 0.85
skip_content_with_lengthFunction · 0.85
read_content_with_lengthFunction · 0.85

Tested by

no test coverage detected