Related fields supporting proxy and compression in HTTP

Source: Internet
Author: User

I have never been confused about how the HTTP protocol supports proxy. Today I suddenly realized it.

The HTTP protocol has a Host field.

If we want to access http://www.sohu.com

Usually get http://www.sohu.com HTTP/1.1

In this way, you can directly connect to the host www.sohu.com. If the host is www.sohu.com, the request-Uri can be a relative path, for example, get/HTTP/1.1

If we have a LAN proxy server, port 192.168.1.2 is 80.

// The following should be an error. The host should have nothing to do with the proxy ,??

When constructing an HTTP request, we need to set the Host field in the request-header.

In this way, the HTTP protocol knows that an HTTP request is sent to port 80 of 192168.1.2, And the request target is a http://www.sohu.com.

//---------------

We only need

Port 80 of 192.168.1.2 initiates a TCP connection and

Get http://www.sohu.com HTTP/1.1 can be sent to it.

As for how 192.168.1.2 helped us get the http://www.sohu.com, it is its thing, the administrator needs to configure an HTTP proxy server, response proxy protocol.

We know that most of the content transmitted by HTTP (hypertext protocol) is text. If it can be compressed, it will greatly save traffic.

Therefore, the HTTP protocol has related fields, such as content-encoding in the Entity header and transfer-encoding in the general header. The former corresponds to the entity body and the latter corresponds to the message body.

Without the latter, the message body is equivalent to the entity body.

Content-encoding and transfer-encoding parameters include chunked and gzip. Generally, HTTP servers support gzip compression.

Therefore, in the mobile Internet era, if we want to develop quickly and save traffic

We recommend that you use the HTTP protocol. First, proxy and compression are supported.

If the native TCP protocol is used, additional development work is required. Especially, proxy is more troublesome.

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.