Fixed bug: answer contained the headers on HTTP error

This commit is contained in:
tastytea 2018-04-03 00:52:06 +02:00
parent 87fded18db
commit 62826f60cf
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
2 changed files with 3 additions and 3 deletions

View File

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

View File

@ -116,11 +116,11 @@ const uint_fast16_t API::http::request(const method &meth,
// Work around "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK" // 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); size_t pos = answer.find("\r\n\r\n", 25);
_headers = answer.substr(0, pos); _headers = answer.substr(0, pos);
// Only return body
answer = answer.substr(pos + 4);
if (ret == 200 || ret == 302 || ret == 307) if (ret == 200 || ret == 302 || ret == 307)
{ // OK or Found or Temporary Redirect { // OK or Found or Temporary Redirect
// Only return body
answer = answer.substr(pos + 4);
return 0; return 0;
} }
else if (ret == 301 || ret == 308) else if (ret == 301 || ret == 308)