1_HTTP protocol detailed

 

1. HTTP protocol detailed

 

2. The compression of the HTTP protocol

The latter will simply make a video to explain.

 

3. Glossary:

HTTP Stateless: Stateless means that no protocol for transaction processing and memory, the server does not know what the client state. On the other hand, open a Web page on a server and you have not opened before any contact between the pages on the server from

If you want to implement a shopping cart, need the help of Cookie or Session or server-side API (such as NSAPI and ISAPI simultaneously submit the information to the server) record this information, the server requests the page Settlement

When you log on to a Web site, you are also logged by the Cookie or Session to "memory" because the server does not know whether you log

Advantages: server memory to allocate memory without connecting to a large number of states for each client, they do not when the client loses connectivity to clean up the memory, to more efficiently to deal with business WEB

Disadvantages: The client requests need to carry each respective parameter, the server needs to process these parameters

 

Likely to commit errors:

. 1, HTTP is a stateless connection-oriented protocol, does not mean stateless HTTP TCP connection can not be maintained, but can not represent the HTTP protocol uses the UDP (connectionless)

2, from the HTTP / 1.1 from the default are turned Keep-Alive, maintaining connection characteristics, simply, when a web page to complete, between the client and the server for TCP HTTP data transmission connection is not closed, if client again visit this page on the server, which will continue to use a connection has been established

3, Keep-Alive not permanently remain connected, it has a hold time, may be set at this time to a different server software (e.g., Apache) in

-------------------------------------

4. Practice:

After the first check mouse click on a link, the browser sends an HTTP request how.

    Under Chrome browser, press F12 to enter developer mode, click Network, click on the link random test page, the following figure appears.

             

The above news.baidu.com is a content-related information issued after clicking the news, in the figure we can see that there are roughly requesting host, IP address, request method and status code is returned (200)

Introduction HTTP request

    http request consists of three parts, a request line, a request header, the request body.

 

An example is given below:

1 POST /login.php HTTP / 1.1 // request comprises a request line method, the request address, protocol version        
2 HOST: www.XXX.com // request header 
3 // blank line, indicating the end of the request header
4 username = admin & password = admin // Cookie request body infos

    Request GET method request information directly to the labeling on the URL, POST data used for submission, submission of information are followed by the body of the request.

    Common request header is as follows:

      referer: contains a URL, page URL on behalf of the user from the starting page to access the current request

      user-agent: its client operating system, browser, and other attributes tell the server

      Host: request of the host name and port number, default 80

      Connection: The current connection is maintained

      Accept-Language: designated to receive natural language

      Cookie: represents the requester identity

      x-forword-for: request on behalf of the IP segment, there may be multiple, separated by commas

  HTTP response Introduction

    HTTP corresponding follows:

 status code:

      1xx : indication information - indicates a request has been received, processing continues
      2xx : Success - indicates that the request has been successfully received, understood, accepted (200 OK)
      3xx : Redirection - further necessary to fulfill the request operation (jump 302 turn)
      4xx : client error - the request has a syntax error or a request can not be achieved (404 requested resource does not exist)
      5xx : server-side error - the server failed to achieve a legitimate request (500 internal server error)

    Common HTTP response headers:

      Server: WEB server names such as: Server: Apache / 1.3.6 (Unix)

      Content-Type: text media types

      Content-Length: Body Length (bytes)

      Keep-Alive: stay connected time

      Date: Time Green

      Location: means that the client should go fetch the document when the client sends a request is received again

      Set-Cookie: Cookie information to the client settings

 

0x 02 manual simulation send HTTP

    Students did not manually open Telnet services Baidu how to enable the Telnet service, not much to say here

    CMD interface into the open telnet:

telnet www.baidu.com 80

    Blank black screen, press on the keyboard "Ctrl" key and "]" key, the interface is shown below

Welcome to Microsoft Telnet Client

Escape character is 'CTRL +]'


Microsoft Telnet>

    Press the "Enter" key to display a blank screen, enter the HTTP request (note HOST: There is a space after)

GET /index.html HTTP/1.1
HOST: www.baidu.com

    之后连续按两次“Enter”键,完成HTTP请求发送,显示如下信息

至此,已经成功完成HTTP发送模拟。

5. nc连接实例:

 

转载于:https://www.cnblogs.com/zoushou/p/4123757.html

Guess you like

Origin blog.csdn.net/weixin_33711647/article/details/93837627