HTTP request process (II) -- Telnet simulates HTTP requests

Source: Internet
Author: User
In the previous section "process Introduction", we have a general understanding of the HTTP request process. This article describes how to use Telnet to simulate HTTP requests-access Baidu.
Let's get started!
1. Open "run"-> cmd to enter the command environment;
2. Enter "Telnet www.baidu.com 80", Press enter, and the screen is black. In this case, use the shortcut key "Ctrl +] (right brackets)" to enable the local ECHO function, in this way, we can see what we are playing. (Note that the execution process in this phase and the following processes both require the operation time to be as short as possible, because a long time will be considered disconnected .)

3. Click Enter to edit the status.
4. Enter "Get/HTTP/1.1" and press Enter. In the second paragraph, enter "Host:" And press enter to complete a simple HTTP request, then I submitted the request to the server as long as I press Enter. (Let's take a look at what this means: Get indicates the request method,/indicates the file in the root directory of the request, HTTP/1.1 indicates the HTTP protocol version, and host is a message header, according to some friends, a "Host:" must be added to version 1.1. However, after my experiment, I found that "Host:" can still send requests normally without adding "Host:", but get HTTP must be capitalized, otherwise, the request cannot be sent)

5. We do not need to do this step to receive the server's return, because after we send the request, we only need a few seconds to receive the response from the server. 6. In this way, the request is complete. Below we search in Baidu "1", the address in the browser should be: http://www.baidu.com/s? WD = 1. Check the request.

How are you doing? The above is only a GET request, of course, you can also use the POST method for the request, but post I am not convenient to do experiments, so I will not write it. For details about the format, refer:
Post/localhost/login. aspx HTTP/1.1
Host:
Content-Type: Application/X-WWW-form-urlencoded
Content-Length: 10

Uid = xxxxxx

Refer:
1. Explanation of the HTTP protocol
2. For more information about HTTP request headers, see http://hi.baidu.com/?##/blog/item/13c2e3ddb3a133ee77c638cd.html.

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.