MCPcopy Create free account
hub / github.com/acl-dev/acl / getBody

Method getBody

lib_acl_cpp/src/http/HttpServletRequest.cpp:615–643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615bool HttpServletRequest::getBody(string& out, size_t body_limit /* 1024000 */)
616{
617 acl_int64 dlen = (acl_int64) getContentLength();
618 if (dlen <= 0 || dlen > (acl_int64) body_limit) {
619 return false;
620 }
621
622 out.space((size_t) dlen + 1);
623 body_parsed_ = true;
624 istream& in = getInputStream();
625
626 ssize_t n;
627 char buf[8192];
628
629 while (dlen > 0) {
630 n = (ssize_t) sizeof(buf) - 1 > (ssize_t) dlen ?
631 (ssize_t) dlen : (ssize_t) sizeof(buf) - 1;
632 n = in.read(buf, (size_t) n);
633 if (n == -1) {
634 return false;
635 }
636
637 dlen -= n;
638 buf[n] = 0;
639 out.append(buf, (size_t) n);
640 }
641
642 return true;
643}
644
645string* HttpServletRequest::getBody(size_t body_limit /* 1024000*/)
646{

Callers 5

mainFunction · 0.80
http_post_okFunction · 0.80
http_post_okFunction · 0.80
http_post_okFunction · 0.80
http_post_okFunction · 0.80

Calls 4

stringClass · 0.50
spaceMethod · 0.45
readMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected