I am authoring a service with a REST API, that gives people the ability to upload certain kinds of documents. I would like these documents to be compressed during upload (for bandwidth reasons) but they are not stored in my service in a compressed manner. I do have a client SDK, but customers are free to implement their own libraries to upload content based on the REST documentation that I put out. I've looked at the top answer here and determined that transfer encoding might be the more appropriate mechanism to do this.
However, there is very scant documentation/examples on enabling transfer encoding during a PUT request. The RFC seems to spend a good deal of text around transfer encoded responses from the server, but not the other way around.
Should I choose to go down this route, I wanted to get clarification on a few things:
- As per RFC 7230, transfer encoding of gzip must always use a second encoding of chunked. In my case, it is not strictly required as the sender does know the full length of the file being sent. But as per the standards I must implement chunked encoding on the server. The RFC indicates that content-length should not be specified if Transfer Encoding is specified, and the chunked encoding framing should be used to delineate the end of the message. Is this accurate? I ask this as my service will need to support chunked-encoding, and I'd like to avoid authoring that if possible.
- For transfer-encoded responses, there is a mechanism (TE: Transfer-Encoding:) for the server to negotiate with the client the algorithm that it supports. But there is no such mechanism for client to server interactions. If for some reason, in future, I want to stop support of gzip transfer-encoding at my service, is there any alternative other than returning back 501 (not implemented) errors to the client? This would be a breaking change of sorts and could render some clients to stop working completely. Ideally, I would like the client to query if the server supports a specific encoding, and only then start sending messages using that encoding. Are there any interesting ways this can be done?