大网数据广告活动
网站运营与故障问答

Does HTTP not support providing a checksum in a form of header for downloaded content?

· 52CE 我爱测

Is there a way to tell a browser downloading a file or page that the content it is downloading should match this checksum made with this formula (e.g. sha-1 or md5)? I think it would be great to verify file integrity without havi…

问题原文

原帖链接 · Alexis Evelyn · CC BY-SA 4.0

Is there a way to tell a browser downloading a file or page that the content it is downloading should match this checksum made with this formula (e.g. sha-1 or md5)?

I think it would be great to verify file integrity without having to manually verify the file's integrity after download.

If it is possible, how would I implement this in my own server? If not, what is the best alternative?

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 4.0

Digest is the standard header used to convey the checksum of a selected representation of a resource (that is, the payload body).

An example response with digest.

>200 OK
>...
>Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
>
>{"hello": "world"}

Digest may be used both in request and responses. It's a good practice to validate the data against the digest before processing it.

You can see the related page on mozilla website for an indepth discussion around the payload body in http.

I guess that whole HTTP-based Internet is working, because we're using TCP protocol

No, the integrity on the web is ensured by TLS. Non-TLS communication should not be trusted. See rfc8446


Source: Roberto Polli's answer to Checksum in HTTP response header - why not?

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-11-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。