0

My team and I have a Tomcat server running a Restfull webservice, implemented using RestEasy:

@POST
@GZIP
@Path("/capture")   
@Consumes(MediaType.APPLICATION_JSON)
Response RecieveData(@GZIP RecievingData recievingData);

We need to make compressed post to this service. The problem is we are not finding an implementation that works.

HTTP/1.1 400 Bad Request [Content-Encoding: gzip, Content-Type: text/html; charset=UTF-8, Date: Thu, 07 Jan 2016 10:07:05 GMT, Server: Apache-Coyote/1.1, Content-Length: 66, Connection: keep-alive]

We are out of ideas and this supose to be a simple function for an HTTP Client. Any ideas?

OBS: Here is the RestEasy Proxy:

@POST   
@GZIP
@Consumes(MediaType.APPLICATION_JSON)
public Response saveData(@GZIP RecievingData customer);

EDIT: Got some changes in the Firewall and the 3rd method changed to an error 400.

  • I'm not familiarized with the `@GZIP` annotation so this is just a thing that may be important or probably not. Beeing a zipped data (in post), wouldn't the parameter for the method be some sort of Stream? As I said, just curios question here... – Jorge Campos Jan 06 '16 at 23:52
  • I find these posts that may be relevant: http://stackoverflow.com/questions/7153484/gzip-post-request-with-httpclient-in-java and http://stackoverflow.com/questions/1450151/can-i-compress-http-requests-using-gzip – Jorge Campos Jan 06 '16 at 23:55
  • We tried the solution on both posts and got nothing. – Marcus Vinicius Bianchi Santos Jan 06 '16 at 23:57
  • 'compressed post' can mean a couple things depending on Request OR Response or BOTH. ie should an interceptor gzip the request body's outStream OR should an interceptro gunzip the response's inStream OR both.. look into wrapping the needed interceptors around your protocol for http connection. – Robert Rowntree Jan 08 '16 at 00:28
  • With plain JAX-RS client or RESTeasy client, try to register [this interceptor](https://github.com/resteasy/Resteasy/blob/master/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/interceptors/encoding/GZIPEncodingInterceptor.java), and setting the `Content-Encoding` header on the request to `gzip` – Paul Samsotha Jan 09 '16 at 04:24

2 Answers2

0

If using Tomcat why not add a RequestFilter that will pre-process received requests that contain header Content-Encoding: gzip and decompress it before the rest of the filter chain handles it?

EDIT: I'm guessing your third option may actually have worked (snoop the network to verify), the issue was you got 403 - Forbidden response from the server. That's a problem with authorization not with the URL, request encoding, or anything else. The GZIP might actually be working for you right now.

EDIT: Your latest output for HTTP response code 400 - Bad Request shows Content-Type: text/html. The Controller is expecting Content-Type: application/json, so the client did not set the ContentType as required by the Controller. Recheck your usage and config of the client code.

Brad
  • 1
  • 1
  • Disregard. You meant client side request submission, not server side request processing. – Brad Jan 07 '16 at 00:37
0

In the end I used the Resteasy framework for server and client to implement the GZIP compression.

Server side: https://docs.jboss.org/resteasy/docs/2.3.0.GA/userguide/html/gzip.html

Client Side: https://docs.jboss.org/resteasy/docs/2.2.1.GA/userguide/html/RESTEasy_Client_Framework.html

That worked for me.