Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it legitimate http/rest to have requests that are compressed?

Tags:

rest

http

I asked this question a few days ago, and I didn't get a lot of activity on it. And it got me thinking that perhaps this was because my question was nonsensical.

My understanding of http is that a client (typical a browser) sends a request (get) to a server, in my case IIS. Part of this request is the accept-encoding header, which indicates to the server what type of encoding the client would like the resource returned in. Typically this could include gZip. And if the server is set up correctly it will return the resource requested in the requested encoding.

The response will include a Content-Encoding header indicating what compression has been applied to the resource. Also included in the response is the Content-Type header which indicates the mime type of the resource. So if the response includes both Content-Type : application/json and Content-Encoding: gzip, the client knows that resource is json that is has been compressed using gzip.

Now the scenario I am facing is that I am developing a web service for clients that are not browsers but mobile devices, and that instead of requesting resources, these devices will be posting data to the service to handle.

So i have implemented a Restfull service that accepts post request with json in the body. And my clients send their post requests with Content-Type:Application/json. But some of my clients have requested that they want to compress their request to speed up transmission. But my understanding is the there is no way to indicate in a request that the body of the request has been encoded using gZip.

That is to say there is no content-Encoding header for requests, only responses.

Is this the case?

Is it incorrect usage of http to attempt to compress requests?

like image 429
David Kethel Avatar asked Oct 22 '22 10:10

David Kethel


1 Answers

According to another answer here on SO, it is within the HTTP standard to have a Content-Encoding header on the request and send the entity deflated.

It seems that no server automatically inflates the data for you, though, so you'll have to write the server-side code yourself (check the request header and act accordingly).

like image 184
Thilo Avatar answered Nov 02 '22 03:11

Thilo