Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Allow gzip responses from MailChimp through DecompressingHttpClient #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

snappieT
Copy link

I've started to get gzipped responses from MailChimp in certain error cases, but the Apache HttpClient doesn't decompress the response before calling EntityUtils.toString. This resulted in a garbage string that later caused JSON parsing errors:

Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2
    at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1505) ~[LeadinJobs-executable.jar:na]
    at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1386) ~[LeadinJobs-executable.jar:na]
    at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:531) ~[LeadinJobs-executable.jar:na]
    at com.google.gson.stream.JsonReader.peek(JsonReader.java:414) ~[LeadinJobs-executable.jar:na]
    at com.google.gson.JsonParser.parse(JsonParser.java:60) ~[LeadinJobs-executable.jar:na]
    ... 16 common frames omitted

This change ensures that GZipped responses are properly decompressed before reading the response content. I've verified this change no longer causes the above exception.

@basiliscus

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant