REST and gzip

Jamsta1912
Tera Guru

Hello all.

I am currently working on a third party integration using REST. The third party want to compress the messages to our ServiceNow instance using gzip. Is there a particular methodology I’ll need to use to decompress the message our end, or is this handled automatically?

Thank you.

Jamie 

1 ACCEPTED SOLUTION

You can test it at your end by sending request to your endpoint by postman or rest api explorer with header

Content-Encoding as gzip

 

 

Hope this helps.

 

Regards

Ujjawal

View solution in original post

8 REPLIES 8

You can test it at your end by sending request to your endpoint by postman or rest api explorer with header

Content-Encoding as gzip

 

 

Hope this helps.

 

Regards

Ujjawal

Ah yes, that does help. I had been testing using hurl.it and I had noticed that by default the messages being generated did have Content-Encoding: gzip. So I think this means it will work fine. Than you again!

Jamie.

John Caruso
Kilo Guru

Hi Jamie,

Apologies for misunderstanding the scenario. In any case, I wanted to point out that HTTP compression is taken care of at the HTTP layer - so whether you use SOAP or REST doesn't really matter. Inbound HTTP requests are ultimately processed via the Apache Tomcat server HTTP stack which routes the incoming HttpServletRequest (GlideServletRequest) through a servlet Filter chain, including a GZip filter. This filter automatically handles outbound compression and inbound decompression of gzip-encoded content.

Also, for your scenario, the incoming request body would be gzip'd. While this can be tested using Postman (w/binary file option and selecting a pre-gzipped file), I am not aware of how this could be tested using REST Explorer, as I see no option for gzipping the request body. In my own testing when setting Content-Encoding: gzip on a PATCH call, I get a 400 error with message "Not in GZIP format". 

I was able to successfully use Postman to send a PATCH with a pre-gzipped request body with the Content-Encoding: gzip header to my Kingston dev instance.

HTH,

John

 

Hello John,

Thank you for taking the time to write up this explanation. It's really helpful to get an understanding of the detail - it was previously a bit too mysterious for me! 🙂