Introduction to the HTTP protocol
HTTP Hypertext Transfer Protocol (Http,hypertext Transfer Protocol) is one of the most widely used network protocols on the Internet. All WWW documents must comply with this standard. HTTP was originally designed to provide a way to publish and receive HTML pages. 1960 American Ted Nelson conceived a way to process text messages through a computer called hypertext (hypertext), which has become the foundation of the HTTP Hypertext Transfer Protocol Standard architecture. The Ted Nelson organization coordinated the World Wide Web Association (Wide) and the Internet Engineering Working Group (Internet Engineering Task Force) to work together to study and eventually release a series of RFCs, of which the famous RFC 2616 defines the HTTP 1.1.
http1.0 and http1.1 differences
HTTP downlevel protocol is often used TCP, in fact, as long as it can provide a stable connection, what protocol for HTTP is possible, this is the layered meaning of network protocol.
HTTP 1.0 Specifies that the browser and the server only maintain a brief connection, each request of the browser needs to establish a TCP connection with the server, the server completes the request processing immediately after disconnecting the TCP connection, the server does not track each customer also does not log past requests. Each time the browser obtains a static page, the page is parsed and the server is always connected again and again, releasing the connection, getting each URL in the page
This is only initially developed when the web is not developed, and now the Web page contains a large number of images, video, and other network files, it is obviously unreasonable, such as a page file containing many images does not contain the real image data content, but only to indicate the URL address of these images, When a Web browser accesses this Web page file, the browser first issues a request for that Web page file, and when the browser resolves the HTML content in the Web document returned by the website, the image label is found The browser will again issue a request to the server to download the image data based on the URL address specified by the SRC attribute in the tag.
After http1.1, a persistent session connection is supported, and multiple HTTP requests and responses can be delivered on a TCP connection, reducing the consumption and latency of establishing and shutting down the connection. Multiple requests and responses for a Web page file that contains many images can be transferred in one connection, but requests and responses for each individual Web file still need to use their own connection. HTTP 1.1 also allows the client to make the next request without waiting for the last request result to be returned, but the server side must echo the response in the order in which the client requests are received, to ensure that the client can distinguish the response from each request. This also significantly reduces the time required for the entire download process.
In contrast, the browser parses the webpage as an example:
As you can see, HTTP 1.1 overcomes the performance issues of HTTP 1.0, based on the advantages of HTTP 1.0. Not only that, HTTP 1.1 also improves and expands the functionality of HTTP 1.0 by adding more request headers and response headers. For example, because HTTP 1.0 does not support host Request header fields, Web browsers cannot use host header names to explicitly indicate which Web site to access on the server, so you cannot use a Web server to configure multiple virtual Web sites on the same IP address and port number. After adding the host Request Header field in HTTP 1.1, the Web browser can use the host header name to explicitly indicate which Web site to access on the server, which enables multiple virtual Web sites to be created on a single Web server with a different hostname on the same IP address and port number. HTTP 1.1 Persistent connection, also need to add new request header to help implement, for example, when the value of the connection request header is keep-alive, the client notifies the server to keep the connection after returning the result of the request, and when the value of the connection request header is close, The client notifies the server to close the connection after returning the result of this request. HTTP 1.1 also provides request headers and response headers related to mechanisms such as authentication, state management, and cache caching.
In HTTP we can achieve the http1.0 era of functions such as: file breakpoints continue to pass
the current http1.0 protocol, though much more http1.0, is still unable to meet our requirements for a growing network of resources, so we urgently need the next-generation HTTP protocol to meet our requirements:
Since the HTTP protocol makes a stateless protocol, once the connection is closed and opened again, the server will not remember what we have done, or what we should do next, although we can use cookies to implement the labeling of users, but also very troublesome Ah, in addition the HTTP protocol makes passive, a request, A reply, can not request multiple replies at once, for example, our web page contains multiple connections, why the server can not be in our first request, we have all the resources to reply, sent to us, although such a mechanism is good, but now the http1.1 can not be achieved,
So we need the next generation HTTP protocol to implement, although now the current HTML5
The standard Websoket protocol can implement client and server side, duplex communication, WebSocket protocol is HTML5 a new protocol. It is the implementation of the browser and server full-duplex communication (Full-duplex), but there are many browsers have not been supported, universal application is also very difficult. So many Web sites in order to achieve instant messaging, the technology used are polling (polling). Polling is at a specific time interval (such as every 1 seconds), the browser sends an HTTP request to the server, and the server returns the latest data to the client's browser. This traditional HTTP request pattern has obvious drawbacks – the browser needs to constantly make requests to the server, but the header of the HTTP request is very long, and the data contained in it may be a small value, which consumes a lot of bandwidth.
And the most new technology to do polling effect is comet– using AJAX. However, although this technology can reach full-duplex communication, it still needs to make a request.
Specific WebSocket protocol resolution can be referenced in this article:
Http://www.myexception.cn/web/2047919.html
And this article: http://www.51edu.com/it/bckf/76471.html
Views on the network for next-generation HTTP protocols: 1 INTRODUCTION
WWW has been a great success, HTTP is the core of success, it is used to exchange information on the Web. The current web follows the http/1.x, but it lacks modularity and performance is thus poor.
Http/1.x consists of three layers, but it is not clearly distinguishable: message transfer, universal remote method invocation, and a series of methods for document processing. The lack of modularity makes the development of HTTP very difficult and poses problems for other applications, which are based on HTTP, and therefore must include many HTTP designs, regardless of the suitability of the technology. Other common calling systems (such as CORBA, DCOM, JAVA
RMI) is also located above http. Problems caused by http/1.x lack of modularity include:
。 In http/1.1, the division of message boundaries is not done in a separate layer, but is mixed with other functions, resulting in five different ways of dividing the boundaries of the message, very complex.
。 General application Tunneling (tunneling) technology is done through HTTP document fetching and tabular processing methods (get and post), which makes it difficult for firewalls to discover the semantic content of a given communication, making it difficult to implement security policies.
。 The invocation layer of HTTP is very difficult to distinguish from document processing applications, and the designers of other applications do a lot of work in understanding how to use the calling layer functionality for their own applications.
On the other hand, the HTTP protocol opens a new TCP connection for each HTTP session (the process of a request and response), which is a waste of system and network resources.
To overcome these problems, the World Wide WEB Consortium has been studying the development of next-generation HTTP protocol curriculum ttp-ng since 1997.
2 Structure of the Http-ng
The structure of the http-ng is a three-layer system 1, the top layer is the application layer, the middle is the message layer, the bottom is the transport layer. The interface of the application layer and the message layer is called the harass ⒔ recurrence, and the interface between the message layer and the transport layer is called the "Transport Interface"
2.1 Application Layer
Applications defined in HTTP 1.1 include obtaining web pages, processing proxies and caches, and submitting tables using CGI descriptions. It uses methods such as, post, and put. In Http-ng, these applications are abstracted into traditional Web applications metrics he
Classic Web
Application? TCWA). The system uses a mechanism to determine which method is appropriate for which resource. A web resource that supports TCWA supports TCWA objects and accepts only the TCWA
The method specified by the API.
The mechanism for defining a new method supports both static and dynamic types, and dynamic types are useful when parameter types need to be extended in the future or when parameters have more than one type. The actual type of a dynamic type parameter that can be determined at run time. Http-ng type system vs. java
The Rmi,corba and DCOM protocol type systems work together so that the APIs in these systems do not need to use tunneling (tunneling) technology to map directly to Http-ng. It provides functional compatibility with other types of systems.
Http-ng's application layer is based on specific applications, and different applications have different interfaces. It allows multiple applications to exist together, enabling the addition of new applications without interfering with the original application. Http-ng transforms existing applications to a better technology base.
2.2 Message Layer
The message system describes a grouping (marshaling) method for the value of a type system in the application layer that can represent a type. The marshalling method is straightforward, independent of the calling method or the currently supported application. The marshalling method is based on the external data representation of the IETF XDR,XDR is widely implemented in distributed systems. The parameters and results of all methods are expressed in the system, so no matter how many applications or how many methods are defined in the application system, there is no increase in the complexity of marshalling a request or reply message.
The message layer is primarily a request-answering message protocol, like an HTTP
1.1, but it improves performance in several ways, such as using the cache and binary message formats to reduce the number of bytes actually transferred, while also reducing the CPU time required to group messages, http-ng the message layer with additional control information, and further reducing bandwidth requirements by establishing session characteristics. Another performance improvement comes from using the application layer's type system to eliminate dependencies between each head, thus reducing the complexity of the implementation.
The message format is now known as W3ng, which leverages the technology of session caching, which has been used for DCE RPC, JAVA
RMI. For example, when a method or resource is called for the first time, the entire identity is transmitted in the reply message, at which point both parties cache the connection. In subsequent method calls, only a small integer value corresponding to a particular connection is needed in the transport instead of the original identity. Further, these caches can be loaded by both parties when the connection is established, which is particularly useful for some standard applications.
The delivery of a target resource for a method call is relative to the previous target. Instead of passing the identity of the entire resource, the system passes and connects the different parts of the last resource identity. The receiving party re-constructs the identity by modifying these differences in the last accepted identity.
HTTP-NG's message format is binary, unlike the text-based format in HTTP-1.1, where the binary format improves performance in two ways. First, a non-string value does not need to be converted by the sender to a string, and then the receiver decodes it. Instead, you can use valid operations such as memcpy to copy directly from the memory representation of these values. Second, these values use a binary representation that is less than the number of bytes spent in a string representation.
The techniques used by the HTTP-NG message layer can significantly reduce overhead compared to existing protocols.
2.3 Transport Layer
Http-ng supports specific applications made up of transport stacks that can manipulate messages that pass through them. The transport layer allows the composition of the transport stack to be arranged in a number of sequential ways, it can provide multiple virtual connections over a reliable byte stream, such as TCP/IP, and it can also provide a two-way use of a single byte stream, so that the server does not need to open the additional byte stream to call back the customer. It also provides a token of the message bounds above the underlying byte stream, which can be used to support high-level message-based systems. It allows messages to be transferred in chunks or shards, which can be reused for simultaneous messages, and can be used to quickly send data values (such as file size information at the beginning of a GIF file) to the beginning of a data segment.
The Webmux stack for http-ng is a very useful synthesis of transport components. It is directly above the TCP/IP and is located under the marshalling layer, but it can also be connected to other transport components such as compression and security components. The WEBMUX layer is marked for logging and supports the Shard of the message. It provides optional transport flow control so that the receiver can control the transmission rate of the sender. It supports the reuse of up to 252 virtual connections on a single underlying connection. Each virtual connection allows for a different transport stack on the WEBMUX layer. In addition, the WEBMUX layer provides the endpoint (Endpoint) identity for both sides of the connection, which makes it easier for the server to call the customer back with the same connection. Since the delivery endpoint identification method is already defined, the firewall can also be inserted when necessary.
3 Web browser and server architecture
Apply to at least two types of participants in the Web: Web browsers and Web servers. The Web browser and Web server in the HTTP-NG protocol may be structured as shown in 2, 3. The Web server has more kinds of protocols and transport components in order to handle many types of customers. The server in Figure 2 supports HTTP and supports the HTTP-NG protocol, while the Web browser in Figure 3 supports only http-ng. The server can support Http-ng messages on a normal TCP/IP transport, and the browser expects a MUX protocol on each server. The browser in the figure can support digital character signing document processing, and the server cannot. Both the browser and the server use compression in the message flow. Of course, many other possible transport protocols can also be applied. A proxy server has both client functionality and server-side functionality.
Talking about http1.0 and http1.1 (1.x) and Http-ng