Differences between HTTP proxy and HTTP Proxy

Source: Internet
Author: User

Winsock provides two methods for HTTP proxy to submit HTTP requests.
1. Direct Request
2. Connect to the remote server and submit an HTTP request like a common request.

Let's talk about the first method:

Let's talk about the common process of submitting an HTTP request:
After connecting to the remote server directly, submit the HTTP header to the server when the connection is successful. Check the approximate format.
Get, HTTP, 1.1
Accept :*/*
Accept-language: ZH-CN
UA-CPU: x86
Accept-encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; sv1;. Net CLR 1.1.4322;. Net CLR 2.0.50727)
HOST: www.baidu.com
Connection: Keep-alive

Let's take a look at the proxy connection method.
First connect to the proxy server (IP address, port), and then submit such an HTTP header to the Proxy Server
Get http://www.baidu.com/https/1.0
Accept :*/*
Accept-language: ZH-CN
UA-CPU: x86
Accept-encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; sv1;. Net CLR 1.1.4322;. Net CLR 2.0.50727)
HOST: www.baidu.com
Proxy-connection:
Keep-alive

DifferencesThat's all,
1. The connection is not the IP address and port of the target server, but the IP address and port of the proxy server.
2. Submit an HTTP address instead of a relative address.
3. Connection:Keep-aliveAnd
Proxy-connection:
Keep-alive
OfDifferences

Let's talk about the second method:
In fact, this method is very powerful, in addition to implementing HTTP proxy, but also other TCP/IP protocol processing.
Such as pop2, SMTP, FTP, etc.
First, let's look at the theory. In fact, after the client connects to the proxy server, let the proxy server connect to the remote server.
After the connection is successful, the connection result is returned to the client. Then, the client determines the result. If the connection is successful, normal data is directly sent to the proxy, and the proxy receives the data.
It is actually a transfer station. It is different when the connection starts. All subsequent communications can be operated as usual.

The client first connects to the proxy server and then submits a request to the proxy server to tell him where to connect:
Connect www.baidu.com: 80 HTTP/1.1
Accept :*/*
Content-Type: text/html
Proxy-connection:
Keep-alive

Content-Length: 0

At this time, if the proxy server is successfully connected, such a piece of information will be returned (the client receives the information, note, do not disconnect at this time, huh, huh)
HTTP/1.0 200 connection established
Proxy-AGENT: CCProxy 6.4.2 'here is the name of the proxy program. Check what proxy software you are using.

Then you can send a normal request.
Get, HTTP, 1.1
Accept :*/*
Accept-language: ZH-CN
UA-CPU: x86
Accept-encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; sv1;. Net CLR 1.1.4322;. Net CLR 2.0.50727)
HOST: www.baidu.com
Connection:Keep-alive

Then you can receive the webpage information sent from the remote server.

How can I determine whether the returned message has been received? Sometimes messages are returned in several segments.

This depends on the Protocol. If it is an HTTP protocol, you can determine it in two ways.
1. determine the size of the data to be received through the value of Content-Length. If the data is enough, the connection is disconnected. Note that the data size of the HTTP header is not counted.
2. Change "connection" in http:CloseThe server automatically disconnects after sending the message. You do not need to determine when to disconnect the message.
You receive the data.CloseYou can disconnect the connection during the event.

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.