| 942 | } |
| 943 | |
| 944 | bool 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 | |
| 993 | int http_request::read_body(char* buf, size_t size) |
| 994 | { |
nothing calls this directly
no test coverage detected