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

Method body_gets

lib_acl_cpp/src/http/http_request.cpp:944–991  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

942}
943
944bool http_request::body_gets(string& out, bool nonl /* = true */,
945 size_t* size /* = NULL */)
946{
947 if (size) {
948 *size = 0;
949 }
950 if (client_ == NULL) {
951 logger_error("connection not opened yet");
952 return false;
953 }
954
955 if (conv_ == NULL) {
956 if (client_->body_gets(out, nonl, size)) {
957 return true;
958 } else {
959 if (client_->disconnected()) {
960 // Do nothing.
961 }
962 return false;
963 }
964 }
965
966 size_t n, size_saved = out.length();
967 string line(1024);
968 if (! client_->body_gets(line, nonl, &n)) {
969 if (!line.empty()) {
970 conv_->update(line.c_str(), line.length(), &out);
971 }
972 conv_->update_finish(&out);
973 if (size) {
974 *size = out.length() - size_saved;
975 }
976 if (client_->disconnected()) {
977 // Do nothing.
978 }
979 return false;
980 }
981
982 if (!line.empty()) {
983 conv_->update(line.c_str(), line.length(), &out);
984 }
985 conv_->update_finish(&out);
986 if (size) {
987 *size = out.length() - size_saved;
988 }
989
990 return true;
991}
992
993int http_request::read_body(char* buf, size_t size)
994{

Callers

nothing calls this directly

Calls 6

disconnectedMethod · 0.80
update_finishMethod · 0.80
lengthMethod · 0.45
emptyMethod · 0.45
updateMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected