summaryrefslogtreecommitdiffstats
path: root/fbench
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahoo-inc.com>2017-05-10 12:51:44 +0200
committerArne H Juul <arnej@yahoo-inc.com>2017-05-10 12:51:44 +0200
commitc313649c622f12a9fc2ef52858d46c1771127f12 (patch)
tree6138097913ddf2790fa7e39fddf78f2e80be7b92 /fbench
parenta9cb46c809197e72bd0ef99c8ec8704349cc25df (diff)
put newline between content lines
Diffstat (limited to 'fbench')
-rw-r--r--fbench/src/fbench/client.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/fbench/src/fbench/client.cpp b/fbench/src/fbench/client.cpp
index 330c62703af..5981c2dfcf2 100644
--- a/fbench/src/fbench/client.cpp
+++ b/fbench/src/fbench/client.cpp
@@ -57,7 +57,7 @@ public:
bool reset();
int findUrl(char *buf, int buflen);
int nextUrl(char *buf, int buflen);
- int getContent();
+ int nextContent();
const char *content() const { return _contentbuf; }
~UrlReader() { delete [] _contentbuf; }
};
@@ -118,13 +118,15 @@ int UrlReader::nextUrl(char *buf, int buflen)
return ll;
}
-int UrlReader::getContent()
+int UrlReader::nextContent()
{
char *buf = _contentbuf;
int totLen = 0;
- while (totLen < _contentbufsize) {
+ int nl = 0;
+ while (totLen + 1 < _contentbufsize) {
int left = _contentbufsize - totLen;
- int len = _reader.ReadLine(buf, left);
+ // allow space for newline:
+ int len = _reader.ReadLine(buf, left - 1);
if (len < 0) {
// reached EOF
return totLen;
@@ -136,7 +138,9 @@ int UrlReader::getContent()
return totLen;
}
buf += len;
- totLen += len;
+ *buf++ = '\n';
+ totLen += nl + len;
+ nl = 1;
}
return totLen;
}
@@ -209,7 +213,7 @@ Client::run()
if (linelen + (int)_args->_queryStringToAppend.length() < _linebufsize) {
strcat(_linebuf, _args->_queryStringToAppend.c_str());
}
- int cLen = _args->_usePostMode ? urlSource.getContent() : 0;
+ int cLen = _args->_usePostMode ? urlSource.nextContent() : 0;
_reqTimer->Start();
auto fetch_status = _http->Fetch(_linebuf, _output.get(), _args->_usePostMode, urlSource.content(), cLen);
_reqTimer->Stop();