I need to implement for one of my network requests a way to decompress gzip then decode base 64 and then convert the bytes to String. I am using retrofit and have implemented as shown below.
I have tried to implement it myself using this answer ( okhttp 3: how to decompress gzip/deflate response manually using Java/Android) but to no success.
I have also tried to leave it blank because apparently, okhttp does this manually but whatever I do I get the results shown below.
Implementation of retrofit
.connectTimeout(connectTimeout, TimeUnit.SECONDS)
.writeTimeout(writeTimeout, TimeUnit.MINUTES)
.readTimeout(readTimeout, TimeUnit.MINUTES)
.build();
if (User.getInstance().isDevMode()) {
retrofit = new Retrofit.Builder()
.client(client)
.baseUrl(App.getContext().getResources().getString(R.string.dev_server))
.addConverterFactory(ScalarsConverterFactory.create()).build();
}
The expected results once I have decompressed the data and decoded should be a string for example "Failed: Bad internet" (much longer normally).
The actual results are for example:
��m�]��k{�ȵ.�W��yNw�lJA/G��[˶bɭN&�HED ��b����>k��"APm'�{�[ Q�������]W���ί������q!�����y��_���^,���'�Cz+b�dg��G?���$�y��t�T�<aI:��-�/���g6�d<e��HYr��Op<��fi�U���m��?�?,eƷ���/���_�iG�7�����y����E��ןZG/?�i]�\��>������_�.>\����_�<̋)�h�ہg�|�ķ�G�1�m~x*��,��~<Y!"}��o���e��_9Γ���f2�l�0���Wy*e__�O��){'�;��_�I���1�a�����^֥����"���0_�Xx�)�z8N�8O�Oq���~�a���o.�.7��'o�x������,g�e�Å�����H���K�՛���E��<ϗ�_��e�L��b,��D,�Ǔd�ϴ��B+�\0��_���oxF��[�i�*�R1f?�W }U�Y�pt*�$��,/�ٶ�x��d.iI^]�����Ǻ g!�_�ҤX�?/E��2��a���$?ø<-$�rO���i���p�L�y