在REST API响应校验 [英] Checksums in REST API responses

查看:170
本文介绍了在REST API响应校验的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是个好主意,发送校验与响应的内容?如果是这样,什么是计算校验和最常用的方法是什么?

例如:

  HTTP / 1.1 200 OK
日期:星期四,2011 GMT 21时三十二分20秒06月30日
服务器:Apache
连接:关闭
内容类型:应用程序/ JSON22
{测试:1}


解决方案

有关HTTP底层协议是已经有一个校验机制,TCP,所以我认为这将是无用的。

如果您仍然需要这种东西,你可以在你的回应计算的主体内容的SHA1签名,并把它作为一个自定义标题,像

  HTTP / 1.1 200 OK
日期:星期四,2011 GMT 21时三十二分20秒06月30日
服务器:Apache
连接:关闭
内容类型:应用程序/ JSON
的X校验:40325305549f7a09edb51ff8df9528ffd8434ac6

Is it a good idea to send a checksum with the content of the response? And if so, what is the most common way to calculate the 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}

解决方案

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

If you still need this kind of thing you could calculate a SHA1 signature of the body content and include it as a custom header in your response, 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

这篇关于在REST API响应校验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆