Deep understanding of the HTTP protocol through Telent, PHP

Source: Internet
Author: User

HTTP protocol : The simple point is how the client asks. How the server answers.

Importance:WebService or Rest do a large architecture is inseparable from the understanding of the HTTP protocol, and even can be simplified to say WebService = http + xml;rest = http + json, various APIs, but also with http+ Xml/json to Realize.

Make a thief stand. Ajax also requires an understanding of the HTTP protocol.

Work Flow:

1) First the client and server need to establish a connection.

Just click on a hyperlink. The HTTP work starts.

2) After the connection is established. The client sends a request to the server. The format of the request is: Request Line (Request method "Get/post/delete/put". Request agreement. Request path). Request header, request subject information

3) When the server receives the request, it gives the corresponding response information in the form of a status line. Contains the protocol version of the information, a successful or incorrect code, followed by MIME information containing the server information, entity information, and possible content.

4) The information returned by the client receiving server is displayed on the user's display via the browser, and then the client disconnects from the server


Request Method: Get,post,head

HEAD and get are basically the same, just not returning content. For example, we need to determine a state, just want a return status code 200. On the head.

Then, look at the difference:


Put writes information to the server, and the server does not necessarily support it.

TRACE is the use of proxies to see if the agent has changed its own HTTP request;

Optinos return to server available methods in header information returned available method server may not support

GET  /test.php Http/1.1host:127.0.0.1//server may not support put/test.php Http/1.1host:127.0.0.1content-length:5trace  /test.php http/1.1host:127.0.0.1content-length:5/Return to server available method  in header information returned available method server may not support Optinos   / test.php Http/1.1host:127.0.0.1content-length:5optinos//Return to server available methods


Explained by the command line:

Get method:



CTRL + "then enter to open the more specific information.


Send to server data via post:




Status code: Server return condition

Okserver successfully returned to the Web page.

301/2 Permanent/Temporary redirection

304 Not modify unchanged

307 is used to maintain the original data, such as a form form for post submission, this time from the orientation. Assuming that it is not 307, but the other, the jump will result in data loss. At this time with 307, it will also send a post to jump

Failed:

404 Not Found, visit page does not exist

Server Internal Error

503 Server is temporarily unavailable





State text, easy to see status code

Deep understanding of the HTTP protocol through Telent, PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.