Fixed 'gzip' header processing

This commit is contained in:
alexzatsepin 2017-02-20 15:22:06 +03:00 committed by Arsentiy Milchakov
parent b116db8dfb
commit 96b7570952
4 changed files with 12 additions and 3 deletions

View file

@ -103,7 +103,7 @@ public class PlacePageView extends RelativeLayout
private static final String PREF_USE_DMS = "use_dms";
//TODO: remove this after booking_api.cpp will be done
private static final boolean USE_OLD_BOOKING = true;
private static final boolean USE_OLD_BOOKING = false;
private boolean mIsDocked;
private boolean mIsFloating;

View file

@ -45,6 +45,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
public final class HttpClient
{
@ -201,7 +202,10 @@ public final class HttpClient
InputStream in;
try
{
in = connection.getInputStream();
if ("gzip".equals(connection.getContentEncoding()))
in = new GZIPInputStream(connection.getInputStream());
else
in = connection.getInputStream();
}
catch (IOException e)
{

View file

@ -8,6 +8,11 @@
namespace platform
{
HttpClient::HttpClient(string const & url) : m_urlRequested(url)
{
m_headers.emplace("Accept-Encoding", "gzip");
}
HttpClient & HttpClient::SetUrlRequested(string const & url)
{
m_urlRequested = url;

View file

@ -37,7 +37,7 @@ public:
static auto constexpr kNoError = -1;
HttpClient() = default;
HttpClient(string const & url) : m_urlRequested(url) {}
explicit HttpClient(string const & url);
// Synchronous (blocking) call, should be implemented for each platform
// @returns true if connection was made and server returned something (200, 404, etc.).