diff options
author | Arne H Juul <arnej@yahoo-inc.com> | 2017-05-09 14:04:18 +0200 |
---|---|---|
committer | Arne H Juul <arnej@yahoo-inc.com> | 2017-05-09 14:04:18 +0200 |
commit | ca6b491fd3832111d4cd0b910d43b90ece7044e1 (patch) | |
tree | d4f762412ff2d5f179597ee1ab5f062ee0b3548c /fbench | |
parent | e1831a2dedfaef5e85c2dcca30505c4f87a5dcd6 (diff) |
only send Content-Length for POST
Diffstat (limited to 'fbench')
-rw-r--r-- | fbench/src/httpclient/httpclient.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/fbench/src/httpclient/httpclient.cpp b/fbench/src/httpclient/httpclient.cpp index ba2f593a76c..3a4cb68aa19 100644 --- a/fbench/src/httpclient/httpclient.cpp +++ b/fbench/src/httpclient/httpclient.cpp @@ -121,28 +121,27 @@ HTTPClient::Connect(const char *url, bool usePost, const char *content, int cLen assert(req != NULL); } + if (!_keepAlive) { + headers += "Connection: close\r\n"; + } + headers += "User-Agent: fbench/4.2.10\r\n"; + // create request - if(_keepAlive) { + if (usePost) { snprintf(req, req_max, - "%s %s HTTP/1.1\r\n" + "POST %s HTTP/1.1\r\n" "Host: %s\r\n" "Content-Length: %d\r\n" - "User-Agent: fbench/4.2.10\r\n" "%s" "\r\n", - usePost ? "POST" : "GET", url, _authority.c_str(), cLen, headers.c_str()); } else { snprintf(req, req_max, - "%s %s HTTP/1.1\r\n" + "GET %s HTTP/1.1\r\n" "Host: %s\r\n" - "Connection: close\r\n" - "Content-Length: %d\r\n" - "User-Agent: fbench/4.2.10\r\n" "%s" "\r\n", - usePost ? "POST" : "GET", - url, _authority.c_str(), cLen, headers.c_str()); + url, _authority.c_str(), headers.c_str()); } // try to reuse connection if keep-alive is enabled |