Why HTTP protocol is designed in plain text way?

2019-01-18 02:11发布

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?

10条回答
霸刀☆藐视天下
2楼-- · 2019-01-18 02:41

Many Internet application protocols use more or less plain text for the protocol (see FTP, POP, SMTP, etc.).

It makes interoperability and troubleshooting much easier.

查看更多
该账号已被封号
3楼-- · 2019-01-18 02:51

In the case of http ,some people work on a "binary" version of it, they called it Embedded Binary HTTP (EBHTTP)

http://tools.ietf.org/html/draft-tolle-core-ebhttp-00

查看更多
Explosion°爆炸
4楼-- · 2019-01-18 02:51

Now,HTTP/2 based Binary,it is much less error-prone.

https://http2.github.io/faq/#why-is-http2-binary

查看更多
虎瘦雄心在
5楼-- · 2019-01-18 02:53

I like the:

...preferred in the Unix world.

reason, but it doesn't go into any explanation for why.

In order to understand why you need to place yourself into the shoes of a designer that wants to make a usable product.

A) You can document the shit out of meaningless gibberish (binary).

B) Develop or hope others develop tools that portray your meaningless gibberish in a meaningful way.

or

A) You can document the shit out of meaningful text that takes advantage of language as a tool for a self-documenting protocol.

B) There is no immediate need for additional tools, and additional tools will be much easier to write and debug.

It creates staged delivery and creates something that is easier to comprehend & recall when doing future development. It also creates a situation where a higher level abstraction is no longer necessary.

Imagine a world where setting a header value isn't as simple as dictionary/Map somewhere in your framework. When running into errors you'd have to constantly question whether or not your framework is correct or not, because you couldn't easily see it's doing the right thing without additional tools. That would be the world of HTTP if each framework needed to invent/implement it's own higher level abstraction (browsers come to mind).

Many protocol designer's want efficiency, this design focuses on usability, which is paramount in the software development industry. Unusable tools that are prematurely optimized create an unnecessary burden for software developers, and this burden manifests across the board.

查看更多
登录 后发表回答