What is HTTP protocol

Hypertext Transfer Protocol (Hypertext Transfer Protocol) The HTTP protocol mainly specifies the format that the browser must follow when sending a request to the server and the format that the server must follow when sending a response (response) to the browser. HTTP works by following the following principles: 2) The request can only be sent to the server by the browser. The server can only passively wait for the request and make a response according to the request

Two, HTTP protocol details

HttpWatch Browser Plugin: Used to monitor the content of browser and server communications. Install this plugin on an older version of Firefox

1. HTTP request information

Get /news/hello.html HTTP/1.1 1)GET: Submit method,HTTP protocol provides a total of 7 ways to submit, of which 5 are not commonly used, only use GET and POST What is the difference between GET and POST submission? 2)/news/hello.html: Request resource path, which shows which resource file is accessed under which application 3)HTTP/1.1: Request protocol and version Localhost :8080 -- Specify host name and port to access user-agent: Mozilla/5.0.. Firefox/25.0 -- Specify client version Accept:.. Text/HTML image/* -- The type of data that the client can accept... If the request mode is GET, there will be no content in the requesting entity (the requesting entity is empty). If the request is POST and the request contains data, then there will be content in the request entity.

2. HTTP response information

Part 1: Status line HTTP/1.1 200 OK 1)HTTP/1.1: The protocol and version that the response follows 2)200: Status code, indicating the result of the request processing 200: Indicates that the request processing was successful! 304/307: Request the browser to use the previously cached resource file 404: Request the browser to find the requested resource (maybe the browser's access path is wrong!) 200 OK 404 Not Found 500 Internal Server Error 200 OK 404 Not Found 500 Internal Server Error Content-type: Text/HTML -- The Type of data that is sent to the browser. Text/HTML represents the HTML format of the web page. Content-length: 139 -- The Length of the data that is sent to the browser,139 bytes... Response Entity: This is the content of the file requested by the browser. For example, when the browser requests a hello. HTML file inside the server, the server responds by sending the contents of the hello. HTML file to the browser as the response entity

Supplement 1: When is a GET submission? When is a POST submission?

HTTP protocol provides a total of 7 submission methods, but 5 are not commonly used, only GET and POST submission. A POST submission is made only when a form is used and the method attribute on the form is specified as POST. Anything else is a GET submission (except for Ajax). Question to consider: what is the submission method of the following request? (1) < form action = "#" > < / form > - GET to submit (2) < form action = "#" method = "GET" > < / form > - GET submitted (3) < form action = "#" Method ="POST"></form> -- <a href="http://www.baidu.com"> </a> -- GET submit (5) -- GET submit

Supplement 2: What are the main differences between GET and POST submissions?

Mainly reflected in the request parameter transmission process is not the same! Submit a GET: (mainly used for the request to the server data) 1) GET submission is behind the URL in the address bar by a question mark stitching parameters data submitted to the server Since the data will be displayed in the address bar, if it is a private data, very insecure 2) through the address bar to submit data, the data amount can't more than 1 KB or 4 KB cannot submit more documents 1) POST does not submit data through the address bar, but sends the data to the server through the requesting entity. Because the data is sent through the requesting entity, it is more secure! 2) There is theoretically no limit to the amount of data submitted by the requesting entity! Use scenarios for submitting files: 1) If you simply do a jump, or just visit a webpage, and there is no data in the request, GET is used for submission. 2) If there is data in the request, but the amount of data is not large, and the data is not private, try to use GET submission. 3) If there is data in the request, the amount of data is relatively large or the data is relatively private, it is recommended to use POST to submit. If the file is to be submitted, POST can only be used. HTTP protocol book :<< diagram HTTP protocol >>