为什么 HTTP 协议以纯文本方式设计? [英] Why HTTP protocol is designed in plain text way?

查看:18
本文介绍了为什么 HTTP 协议以纯文本方式设计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天,我和同事讨论了 HTTP.有人问为什么HTTP是以纯文本方式设计的.当然,它可以像 TCP 协议一样以二进制方式设计,使用标志来表示不同类型的方法(POST、GET)和变量(HTTP 标头).那么,为什么 HTTP 是这样设计的呢?是否有任何技术或历史原因?

Yesterday, I have a discussion with my colleagues about HTTP. It is asked why HTTP is designed in plain text way. Surely, it can be designed in binary way just like TCP protocol, using flags to represents different kinds of method(POST, GET) and variables (HTTP headers). So, why HTTP is designed in such way? Is there any technical or historical reasons?

推荐答案

一个原因既是技术性的也是历史性的,文本协议在 Unix 世界中几乎总是首选.

A reason that's both technical and historical is that text protocols are almost always preferred in the Unix world.

嗯,这并不是真正的原因,而是一种模式.这背后的基本原理是文本协议允许您查看网络上发生的事情,只需转储通过的所有内容.您不需要像 TCP/IP 那样需要专门的分析器.这使得调试和维护更容易.

Well, this is not really a reason but a pattern. The rationale behind this is that text protocols allows you to see what's going on on the network by just dumping everything that goes through. You don't need a specialized analyzer as you need for TCP/IP. This makes it easier to debug and easier to maintain.

不仅 HTTP,而且许多协议都是基于文本的(例如 FTP、POP3、SMTP、IMAP).

Not only HTTP, but many protocols are text based (e.g., FTP, POP3, SMTP, IMAP).

您可能想看看Unix 编程的艺术,以获得关于这个 Unix 事物的更详细的解释.

You might want to take a look at The Art of Unix Programming for a much more detailed explanation of this Unix thing.

这篇关于为什么 HTTP 协议以纯文本方式设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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