The Connect method of HTTP proxy protocol http/1.1

Source: Internet
Author: User
Tags base64

We usually use the HTTP protocol is nothing more than get, post these methods, but the content of HTTP is much more than that. For today, the HTTP proxy uses connect. This is not used in web development, if you are not interested, skip it.
Apache is only used as a Web server and will not support this method. If you want to use it, you must install the appropriate software on the server. Such a lot of software, Baidu a bit HTTP proxy server can find a lot.
Connect this method is the role of the server as a springboard, let the server instead of users to access other Web pages, and then the data are returned to the user. This allows the user to access some Web sites that are accessible only on the server, which is the HTTP proxy. Speaking of agents, I think you will grow up under the banner of the party's students are not unfamiliar it. The network we use is known as the celestial LAN, and it has a long way to go from the Internet. So, we have to go over the bumps to touch the world's original look. Oops, accidentally pulled the egg again. Let's talk about the use of the Connect method.
The Connect method needs to use TCP to connect directly, so it is not suitable for web development, but it is not used in web development. If you use the Connect method, first let the server listen to a port to receive the Connect method request. This is what the server software does, we just have to configure it to do, unless you idle bored to implement a server like this. After the server listens on the port and is the client's request, we must tell the proxy server which Internet server we want to access. If I want to access this blog by proxy (www.web-tinker.com), I need to establish a TCP connection, connect to the port that the server listens to, and then send an HTTP header to the server. Here is the content of this HTTP header:

CONNECT www.web-tinker.com:80 http/1.1host:www.web-tinker.com:80proxy-connection:keep-aliveproxy-authorization: Basic *content-length:0

All HTTP headers are similar, with the first line being the method name, the main parameter, and the HTTP version. The next line is a parameter, and finally ends with two line breaks. This HTTP header is actually nothing to introduce, the only point is the asterisk part, this place should fill in the authentication user name and password. Also, the user name and password are in a fixed format. The user name and password are concatenated with a colon, and then BASE64 encoded before they can be used. If the user name is the ABC password is 123, then the asterisk place should be replaced with ywjjojeymw==, that is, abc:123 after BASE64 encoded results.
After the request is sent, the server side responds to the request. If the user name and password validation pass, a response message with a status code of 200 is returned. Although the status code is 200, the status description is not OK, but connection established.
http/1.1 Connection established

If the user name and password validation do not pass. A 407 status code is returned, and the status statement is unauthorized. Indicates that there is no access to the proxy server.
http/1.1 407 Unauthorized

Validation failures sometimes bring a bunch of HTML, which is a bit of a server in order to make the connection failure on the Web page is displayed, if it is not connected by the browser to ignore it. The information returned by these servers differs from one server software to another, regardless of whether validation succeeds or fails validation. For example, some server software returns the code will use http/1.0, and some will be followed by a representative of the server version of the field. This information does not matter, for the data returned by the server, our key is to look at the status code.
After the validation is passed, we can do normal HTTP operations. It is possible to think of the current proxy server as an Internet server that requests connections, which means that you can use GET, post, and so on to request pages on an Internet server as if you were directly accessing a normal server. When we sent the connect request, we had already told the server that we needed to access the Internet server, and I used the blog's URL. Now we are going to visit the homepage of this blog to send a simple GET request.

get/http/1.1host:www.web-tinker.comcontent-length:0

This is the normal GET request operation, I will not say more, so that the operation of the Connect method is complete. If one day the blog is a wall, it can be accessed in this way. But however persuasive outsmart, the harmony of the celestial technology is not only with the IP shield. If you use an HTTP proxy to access YouTube, this super-harmonious site will be intercepted, after all, HTTP is clear text transmission, not only the domain name, as long as the site has a harmonious word will be intercepted. Therefore, this HTTP proxy can only access some websites that have been shielded from the IP, but are not too severe for harmony. If you need to escape the celestial network monitoring, you must use an encrypted connection, such as a SOCK5 proxy or an encrypted VPN. In short, pay attention to harmony.

The Connect method of HTTP proxy protocol http/1.1

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.