• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

http Post with GZIP content

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 4501
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 4501
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Happily living in the valley of the dried frogs with a few tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic