Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

http Post with GZIP content  RSS feed

 
david dabush
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have rest server in Java Spring on Tomcat. One of my apis is to post to the server very big json ~4MB. I want that the client will gzip it and post it to the server. How can I retrieve it with Java and Spring on the server side?

Content-Type : application/gzip Content-Encoding: gzip
 
Ron McLeod
Saloon Keeper
Posts: 1499
210
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you compress your resource in the application and then pass it the server something with a Content-Type of application/gzip, the server will no longer be able to tell the format of the representation (json, xml, csv, etc.).  The compression and expansion of the payload should be managed by the HTTP client and server and it should be transparent to the application at either end.  Here's an example of what the HTTP headers will look like leaving the HTTP client without and with gzip encoding:

Without gzip compression enabled in the client:

With gzip compression enabled in the client:

 
david dabush
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:If you compress your resource in the application and then pass it the server something with a Content-Type of application/gzip, the server will no longer be able to tell the format of the representation (json, xml, csv, etc.).  The compression and expansion of the payload should be managed by the HTTP client and server and it should be transparent to the application at either end.  Here's an example of what the HTTP headers will look like leaving the HTTP client without and with gzip encoding:

Without gzip compression enabled in the client:

With gzip compression enabled in the client:





ok' I did what you told me in rest client named DHC (chrome app).
I am sending now json ~1MB and I dont see and improvement.

my Tomcat:
 
Ron McLeod
Saloon Keeper
Posts: 1499
210
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
david dabush wrote:I am sending now json ~1MB and I dont see and improvement

It sounds like size of the content sent from the client to the server was reduced from 4MB to 1MB.  What other improvements are you expecting?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!