Telnet establish HTTP connection to get Web page HTML content

Source: Internet
Author: User

Telnet can be used to establish an HTTP connection with the server, obtain Web pages, and implement browser functions.
It is very convenient to observe and test the HTTP header. Because the browser does not see the HTTP header.
The steps are as follows:
telnet www.csua.berkeley.edu 
inputget/officers.html http/1.0and 2 times to enter.
at this point, you should see the HTTP response, including the header and body.
because window takes itself to telnet when the input content is not visible, you can download putty and choose Raw TCP connection to connect.

It is important to note the following:
1. GET and HTTP must be capitalized, because many servers require uppercase and lowercase words can cause a connection failure in some servers.

2. HTTP1.1, it is also necessary to add a line to indicate the host, which is http1.1 requirements.
get/officers.html http/1.1
Host:www.csua.berkeley.ed

another reason to add host here is because many sites are in the form of a virtual host, which is required by host to distinguish it from other virtual hosts on the same host.

3.2 returns indicates that the request was sent, because the HTTP request ended with a null line in the last action.

4. Some smarter websites will block out HTTP request that is not a browser, then we need to impersonate the browser and need the set user-agent.
get/officers.html http/1.1
Host:www.csua.berkeley.ed
user-agent:mozilla/5.0 (Windows; U Windows NT 5.1; En-us; rv:1.9.0.5) gecko/2008120122 firefox/3.0.5

5. The package that crawls the HTTP connection can use Wireshark, get the HTTP request and response of the browser, and then connect using Telnet to simulate the browser.

Telnet establish HTTP connection to get Web page HTML content

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.