The historical evolution of HTTP protocol and design ideas

Source: Internet
Author: User
Tags character set http request new features

This article reprinted from: Getting Started with HTTP protocol


HTTP protocol is the basic protocol of the Internet, but also the necessary knowledge of web development, the latest version of HTTP/2 is to let it become a technical hotspot.

This paper introduces the historical evolution and design ideas of HTTP protocol.

First, http/0.9

HTTP is an application-layer protocol based on the TCP/IP protocol. It does not involve packet (packet) transmission, mainly specifies the communication format between the client and the server, using 80 ports by default.

The earliest version was released in 1991 as version 0.9. This version is extremely simple and has only one command get.

Get/index.html

The above command indicates that after the TCP connection (connection) is established, the client requests (request) The Web page index.html to the server.

The protocol stipulates that the server can only respond to HTML-formatted strings and cannot respond to other formats.

When the server is finished sending, close the TCP connection.

Second, http/1.0

2.1 Introduction

May 1996, the http/1.0 release, the content greatly increased.

First, content in any format can be sent. This allows the Internet not only to transfer text, but also to transfer images, video, binary files. This laid the foundation for the great development of the Internet.

Second, besides the GET command, the post command and Head command are introduced to enrich the interaction between the browser and the server.

Again, the format of the HTTP request and response has changed. In addition to the data section, each communication must include the header information (HTTP header), which is used to describe some meta-data.

Other new features include status code, multi-character set support, multipart send (multi-part type), permissions (authorization), caching (cache), content encoding (contents encoding), and more.

2.2 Request Format

The following is an example of a version 1.0 HTTP request.

get/http/1.0 user-agent:mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) Accept: */*

As you can see, this format has changed a lot with version 0.9.

The first line is the request command, and the Protocol version (http/1.0) must be added at the tail. The following is a multi-outfit message describing the client's situation.

2.3 Response Format

The server responds as follows.

http/1.0 OK content-type:text/plain content-length:137582 Expires:thu, Dec 1997 16:00:00 GMT Last-Mo Dified:wed, 5 August 1996 15:55:28 GMT Server:apache 0.84

The format of the response is "header information + a blank line (\ r \ n) + data". Where the first line is "protocol version + status code" + status description.

2.4 content-type Field

With regard to the encoding of characters, version 1.0 stipulates that the header information must be ASCII and the subsequent data can be in any format. Therefore, when the server responds, it must tell the client what format the data is, and this is what the Content-type field does.

The following are the values of some common content-type fields. Text/plain text/html text/css image/jpeg image/png image/svg+xml audio/mp4 video/mp4 application/javascript Application /pdf Application/zip Application/atom+xml

These data types are always called MIME types, and each value includes a first-level type and a two-level type, separated by a slash.

In addition to predefined types, the vendor can also customize the type.

Application/vnd.debian.binary-package

The above type indicates that a binary packet of the Debian system is being sent.

The MIME type can also be used to add parameters at the tail end using semicolons.

content-type:text/html; Charset=utf-8

The above type indicates that a Web page is being sent, and that the encoding is UTF-8.

When requesting a client, you can use the Accept field to declare which data formats you can accept.

Accept: */*

In the above code, the client declares that it can accept data in any format.

MIME type is not only used in the HTTP protocol, but can also be used elsewhere, such as HTML pages.

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/> <!--equal to--<meta charset=" Utf-8 "/>

2.5 content-encoding Field

Since the data sent can be in any format, the data can be compressed and then sent. The Content-encoding field describes the compression method for the data.

Content-encoding:gzip content-encoding:compress Content-encoding:deflate

When the client requests, it uses the Accept-encoding field to indicate which compression methods they can accept.

Accept-encoding:gzip, deflate

2.6 Disadvantages

Major drawbacks of version http/1.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.