Bugfixes: answer was not deleted before filled again; Header/Body separation was broken

This commit is contained in:
tastytea 2018-03-13 13:22:17 +01:00
parent 76ffc28690
commit 311581345a
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (mastodon-cpp
VERSION 0.6.2
VERSION 0.6.3
LANGUAGES CXX
)

View File

@ -112,10 +112,14 @@ const std::uint16_t API::http::request_sync(const method &meth,
break;
}
//request.setOpt<curlopts::Verbose>(true);
answer.clear();
request.perform();
ret = curlpp::infos::ResponseCode::get(request);
ttdebug << "Response code: " << ret << '\n';
size_t pos = answer.find("\r\n\r\n");
// Work around "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK"
size_t pos = answer.find("\r\n\r\n", 25);
_headers = answer.substr(0, pos);
if (ret == 200 || ret == 302 || ret == 307)