Checksums in REST API responses

Can I send a checksum with the content of the response? And if so, what is the most common way to calculate a checksum?

Example:

HTTP/1.1 200 OK Date: Thu, 30 Jun 2011 21:32:20 GMT Server: Apache Connection: close Content-Type: application/json 22 {test:1} 
+7
source share
3 answers

The main HTTP protocol is TCP, which already has a checksum mechanism, so I think it would be useless.

If you still need such a thing, you can calculate the SHA1 signature of the body contents and include it as a custom header in your answer, something like

 HTTP/1.1 200 OK Date: Thu, 30 Jun 2011 21:32:20 GMT Server: Apache Connection: close Content-Type: application/json X-Checksum: 40325305549f7a09edb51ff8df9528ffd8434ac6 
+7
source

You can always use the Content-MD5 header (see RFC 2616 and 1864 ).

+3
source

For what? Basically, TCP pretty much does this for you (since it should be a reliable protocol), so the checksum is less necessary and possibly redundant.

However, if you insisted on this, I would just add the X-Checksum HTTP header.

+1
source

All Articles