Chapter Nine additional protocol based on HTTP functions

Chapter Nine additional protocol based on HTTP functions

To improve the performance and functionality by adding new functions on the basis of HTTP.

First, eliminate bottlenecks SPDY HTTP

  SPDY (SPeeDY) aims to improve the performance of HTTP, load time of Web pages (50%). 

 1.HTTP bottleneck

  Modern requirements: Real-time updates massive user publicly available, there are updates on a server, the content will be fed back to the client interface.

  To achieve the above requirements, HTTP following these bottlenecks (bad):

    ① a connection can only send a request.

    ② request can only start from the client. The client may not receive an instruction other than a response.

    ③ request / response is sent uncompressed header. The more information the greater the delay header.
    ④ send header lengthy. Each time you send each other the same header caused more waste.
    ⑤ compression format data can be arbitrarily selected. Send non-mandatory compression.
 
  [ Ajax solution] Asynchronous JavaScript and XML (Ajax) is an effective use of JavaScript and the DOM (Document Object Model) operations to achieve asynchronous communication means to replace the local web page to load. Since only a portion of page update, in response to the amount of data transmitted is thus reduced. Ajax's core technology is an API called XMLHttpRequest, the HTTP server and can communicate by calling the JavaScript scripting language.
  The use of Ajax real-time access to content from the server, easy to produce substantially high number of requests, the HTTP protocol itself does not resolve the problems.
  
   [ Comet solutions] Once the server has been updated content, Comet will not make a request to wait, but directly to the client returns a response. This is a delayed response by the analog server-side push to the client (Server Push) function. Typically, the server receives the request, it returns a response immediately after processing, in order to realize the push function, Comet will first response in a suspended state, when the server updates the content, and then returns the response. Therefore, once the server is updated, you can immediately feedback to the client. Although you can do real-time content updates, but in order to retain the response, the duration of a connection also becomes longer . Period, in order to maintain the connection will consume more resources . In addition, Comet HTTP protocol itself also remains unresolved problems

 

   [Solution] SPDY HTTP eliminate problems from the protocol level. SPDY is not completely rewrite the HTTP protocol, but the operation in the form of newly added session layer between TCP / IP application layer and the transport layer . At the same time, taking into account security issues, SPDY specified communication using SSL . SPDY added in the form of session layer, controlling the flow of data, but still using the HTTP communication connection is established. Thus, as usual using HTTP GET and POST methods, etc., Cookie and the like, and HTTP packets.

 

   By SPDY, HTTP with the following features:

    ① multiplexed stream: processing a plurality of HTTP requests unlimited single TCP connection.

    ② request priority given to: address the problems caused by low bandwidth slow response.

    ③ HTTP header compression

    ④ push function: to support the initiative to push function data server to the client.

    ⑤ server prompts: Server can automatically remind the client requests resources required.

 
 
Second, using a browser full duplex communication WebSocket
  WebSocket,即 Web 浏览器与 Web 服务器之间全双工通信标准。仍在开发中的 WebSocket 技术主要是为了解决 Ajax 和 Comet里XMLHttpRequest 附带的缺陷所引起的问题。 一旦 Web 服务器与客户端之间建立起 WebSocket 协议的通信连接,之后所有的通信都依靠这个专用协议进行。通信过程中可互相发送JSON、XML、HTML或图片等任意格式的数据。
  【主要特点】
  ①推送功能:支持服务器向客户端推送数据的推送功能。
  ②减少通信量:只要建立起WebSocket连接,就希望一直保持连接状态。而且WebSocket首部信息少,通信量也少。
    ·握手·请 求:为了实现 WebSocket 通信,需要用到 HTTP 的 Upgrade 首部字段,告知服务器通信协议发生改变,以达到握手的目的。
    ·握手·响应:对于之前的请求,返回状态码 101 Switching Protocols 的响应。

  成功握手确立 WebSocket 连接之后,通信时不再使用 HTTP 的数据帧,而采用 WebSocket 独立的数据帧。

  【JavaScript调用WebSocket API】

 

 

 
三、Web服务器管理文件的WebDAV
   WebDAV(Web-based Distributed Authoring and Versioning,基于万维网的分布式创作和版本控制)是一个可对 Web 服务器上的内容直接进行文件复制、编辑等操作的分布式文件系统 除了创建、删除文件等基本功能,它还具备文件创建者管理、文件编辑过程中禁止其他用户内容覆盖的加锁功能,以及对文件内容修改的版本控制功能。

   【拓展概念】:

    集合:是一种统一管理多个资源的概念。以集合为单位可进行各种操作。也可实现类似集合的集合这样的叠加。

    资源:把文件或集合称为资源。

    属性:定义资源的属性。定义以“名称=值”的格式执行。

    锁:把文件设置成无法编辑状态。多人同时编辑时,可防止在同一时间进行内容写入。

  【WebDEV新增的方法和状态码】:
    PROPFIND :获取属性
    PROPPATCH :修改属性
    MKCOL :创建集合
    COPY :复制资源及属性
    MOVE :移动资源
    LOCK :资源加锁
    UNLOCK :资源解锁
  
    102 Processing :可正常处理请求,但目前是处理中状态
    207 Multi-Status :存在多种状态
    422 Unprocessible Entity :格式正确,内容有误
    423 Locked :资源已被加锁
    424 Failed Dependency :处理与某请求关联的请求失败,因此不再维持依赖关系
    507 Insufficient Storage :保存空间不足
   WebDAV 的请求实例和响应实例

 

 

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Guess you like

Origin www.cnblogs.com/qmillet/p/12077429.html