It seems that binary would be more compact and can be deserialized in a standard way, why is text used instead? It seems inefficient and web frameworks are forced to do nothing more than screwing around with strings. Why isn't there a binary standard? The web would be way faster and browsers would be able to load binary pages very fast.
If I were to start a binary protocol (HBP hyper binary protocol) what sort of standards would I define?
HTTP is perfectly capable of handling binary data: images are sent over HTTP all the time, and they're binary. People upload and download files of arbitrary data types all the time with no problem.
Binary framing layer # x protocol, all HTTP/2 communication is split into smaller messages and frames, each of which is encoded in binary format. As a result, both client and server must use the new binary encoding mechanism to understand each other: an HTTP/1.
HTTP/2 uses actual binary commands, i.e. individual bits and bytes which have no representation other than the bits and bytes that they are, and hence have no readable representation. (Note that HTTP/2 essentially wraps HTTP/1 in such a binary protocol, there's still " GET /foo " to be found somewhere in there.)
a plain text is human readable, a binary file is usually unreadable by a human, since it's composed of printable and non-printable characters.
The HTTP protocol itself is readable as text. This is useful because you can telnet into any server at all and communicate with it.
Being text also allows you to easily watch HTTP communication with a program like wireshark. You can then diagnose the source of problems easily.
HTTP defines a way to work with resources
. These resources do not need to be text, they can be images, or anything else. A text resource can be sent as binary by specifying the Content-Encoding
header. Your resource type is specified via the Content-Type
header.
So your question really only applies to the HTTP protocol itself, and not the payload which is the resources.
The web would be way faster and browsers would be able to load binary pages very fast.
I don't think this is true. The slowest part is probably connection establishment and slow TCP start.
Here is an example of how an HTTP response would send a text resource with a binary representation:
HTTP/1.1 200 OK
Server: Apache/2.0
Content-Encoding: gzip
Content-Length: 1533 Content-Type: text/html; charset=ISO-8859-1
Text-based protocols have many important advantages:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With