Thematic -HTTP

                                                                          HTTP

  1.  HTTP ( HyperText Transfer Protocol Hypertext Transfer Protocol)

    [1]TCP+80

    [2] Code Status:

      i.1XX: indicates that the request has been accepted, continue to process the request

      ii.2XX: request has completed processing, for example:

        a) 200 a request has been normally processed

      iii.3XX: indicates the URL locate request to another directory, for example:

        b) 301 requests permanent redirect

        c) 302 requests temporary redirect

        d) 304 the client request is redirected to the local cache

      iv.4xx: Client error, for example:

        a) 400 client request syntax error

        b) 401 has not been authorized client requests

        Request c) 403 is rejected by the server client, typically is no authority

        d) URL 404 in the client requests the server does not exist

      v.5XX: a server-side error, for example:

        a) a permanent error occurs server 500

        b) 503 temporary error occurred on the server side

    [3] distributed, web

  2.HTTPS

    Communication process: symmetric encryption and asymmetric encryption SSL (located between the application layer and transport layer); port TCP + 443;

  3. stateless protocol

    No state is no protocol for transaction processing and memory, the server does not know what the client state.

    Because the Web server have to face a lot of concurrent access to the browser, the Web server processes in order to improve the ability of concurrent access.

  4. connection ( Connection )

    Connection: keep-alive (stay connected) When a web page is opened completed for HTTP data transfer between the client and the server TCP connection is not closed, if the client again visit this page on the server, we will continue to use this one established connection (set time).

    Connection: TCP Representative close after completion of a Request for transmission of data between the HTTP server and the client connection will be closed, when the client sends a Request again, re-establishment of the TCP connection.

  The request method

GET

Makes a request to a specific resource

HEAD

Similar to the GET request, returns a response but not the specific content, for obtaining the header

POST

Submitting data to the processing request specified resource (e.g., file submission form or upload). Data contained in the request body. POST request may result in a revision to establish and / or existing resources to new resources.

PUT

Upload their content to the designated location specified resource

PATCH

It complements the PUT method, used locally known resource update.

DELETE

Requests that the server delete the resource identified by the Request-URL

CONNECT

HTTP / 1.1 protocol can be reserved for connection to the proxy server pipeline mode.

OPTIONS

Returns the server for a particular resource request methods supported by HTTP. It may be transmitted to the Web server using the '*' request to test the functionality of the server.

TRACE

Echo request received by the server, mainly for testing or diagnosis.

  6. GET and POST difference  

    Different [1] Position:? Submitted after the data will be placed GET URL, URL and to divide transfer data between the parameters & linked, as EditPosts.aspx name = test1 & id = 123456 POST method is to place the submitted data?. in the body of the HTTP packet.

    [2] Size Limit: GET submitted data size is limited because there are restrictions on the browser URL length, the data submitted by the POST method is not limited.

    [3]     安全问题:GET方式提交数据,会带来安全问题,比如一个登录页面,通过GET方式提交数据时,用户名和密码将出现在URL上。

  7.工作流程

    [1]     No1:浏览器(192.168.1.6)向服务器(115.239.210.36)发出连接请求。此为TCP三次握手第一步,此时从图中可以看出,为SYN,seq:X (x=0);

    [2]     No2:服务器(115.239.210.36)回应了浏览器(192.168.1.6)的请求,并要求确认,此时为:SYN,ACK,此时seq:y(y为0),ACK:x+1(为1)。此为三次握手的第二步;

    [3]     No3:浏览器(192.168.1.6)回应了服务器(115.239.210.36)的确认,连接成功。为:ACK,此时seq:x+1(为1),ACK:y+1(为1)。此为三次握手的第三步;

    [4]     No4:浏览器(192.168.1.6)发出一个页面HTTP请求;

    [5]     No5:服务器(115.239.210.36)确认;

    [6]     No6:服务器(115.239.210.36)发送数据;

    [7]     No8:客户端浏览器(192.168.1.6)确认;

    [8]     断TCP连接(如果设置keep-alive保持连接)

  8.请求信息

    请求行(请求方法/URL/协议版本)、消息报头(字段名/值)、空行(报头发送完毕)、请求正文

  9.响应消息

    状态行(协议版本/状态码/状态消息)、消息报头、空行、响应正文

  10.解决HTTP无状态的问题

    [1]     Cookies:通过Cookies,服务器就可以清楚的知道请求2和请求1来自同一个客户端

    [2]     Session(会话)ID:服务器客户端创建一个session id

    [3]     通过表单变量和QueryString保持状态,例:www.xxx.com/xxx.aspx?var1=value&var2=value2

    [4]     区别:Cookies将状态保存再在客户端,Session将状态保存在服务器端;Session更加安全不会任意读取客户信息;考虑到减轻服务器性能方面,应当使用cookies。

  11.URL

    [1]     协议://主机:[端口]/路径/[;url-params][?query-string][#anchor]例:http://www.mywebsite.com/sj/test;id=8079?name=sviergn&x=true#stuff

       12.缓存

    [1]     缓存作用:减少的带宽消耗和延迟

    [2]     客户端缓存:未修改返回304(请求被重定向到客户端本地缓存)

    [3]     WEB代理:validation(验证)或者Freshness指定缓存最长时间。

  13.  断点续传

    采用分段的原理,只请求未下载的部分

 

Guess you like

Origin www.cnblogs.com/XZDSF/p/11270325.html