Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/nntpchan-daemon/libnntpchan/mime.cpp
Jeff Becker e67e7a20bd
* more nntpchan-daemon code
* fix keepalive
2017-10-09 11:48:10 -04:00

27 lines
565 B
C++

#include "mime.hpp"
namespace nntpchan
{
bool ReadHeader(const FileHandle_ptr & file, RawHeader & header)
{
std::string line;
while(std::getline(*file, line) && !(line == "\r" || line == ""))
{
std::string k, v;
auto idx = line.find(": ");
auto endidx = line.size() - 1;
while(line[endidx] == '\r') --endidx;
if(idx != std::string::npos && idx + 2 < endidx)
{
k = line.substr(0, idx);
v = line.substr(idx+2, endidx);
header[k] = v;
}
}
return file->good();
}
}