HTTPClient: response body conversion fails when gzip is accepted

1,035 views
Skip to first unread message

Stephan Wissel

unread,
Nov 18, 2017, 3:44:42 PM11/18/17
to vert.x
Trying to wrap my head around this:
I'm fetching a large JSON Array using the http client:

final WebClient client = this.WebClient.create(vertx);
final HttpRequest<Buffer> request = client 
     .post(443, someHost, somePath).ssl(true) 
      /*.putHeader("Accept-Encoding", "gzip")*/
     .putHeader("Content-Type", "application/json;charset=UTF-8"); 


request.as(BodyCodec.jsonArray()).sendJson(body, ar -> {
      final JsonArray receivedData = ar.result().body();
      System.out.println(receivedData);
});

When I uncomment the gzip acceptance, the JSON conversion fails. What do I miss?

Julien Viet

unread,
Nov 19, 2017, 12:28:23 PM11/19/17
to vert.x
Hi,

you need to decode gzip yourself or you can set on WebClientOptions the tryUseCompression flag that will set the Accept-Encoding header and decompress the content for you.

Julien

-- 
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/7479140d-f39a-43d3-a407-634d641e9227%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephan Wissel

unread,
Nov 19, 2017, 6:29:55 PM11/19/17
to ve...@googlegroups.com
Thx Julien,
Missed that option. Appreciate your reply. Will try and report back

You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/Xwl-SsLyWoA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Mobile message, pegged on glass.

Best regards
Stephan H. Wissel
http://www.wissel.net/
Reply all
Reply to author
Forward
0 new messages