As we all know, in domestic GPRS network environments, most users access the Internet using cmwap access points. Cmwap is China Mobile's GPRS proxy for Internet access. Therefore, when creating a connection, you must use a proxy for the connection.
Assume that the url I connect is: http://wap.uc.cn /;
In the standard proxy, it is like this:
Conection to 10.0.0.172: 80
Get http://wap.uc.cn/https/1.1
HOST: wap.uc.cn
However, the program does not have control over the TCP layer in j2s. Therefore, China Mobile defines a private protocol field: X-Online-host. From the specifications of mobile requirements, we only need to connect to the Internet in this way:
Conection to 10.0.0.172: 80
Get, HTTP, 1.1
HOST: 10.0.0.172
X-Online-Host: wap.uc.cn
In fact, for the program, we only need to replace the original connection URL and the host in the HTTP header with 10.0.0.172, and add an HTTP header field: X-Online-host, the value is the original host. Then, you can connect to the Internet through direct connection.
The problem is as follows:
Get, HTTP, 1.1
In the standard proxy protocol specification, the request must be a complete Uri.
This problem does not occur normally, but it is obvious when the requested URL is special.
Suppose my connection URL is: http://wap.baidu.com/logo.gif? Http://wap.uc.cn/uc.png IMG =
Networking using the X-Online-host protocol:
Conection to 10.0.0.172: 80
GET/logo.gif? IMG = http://wap.uc.cn/uc.png HTTP/1.1
HOST: 10.0.0.172
X-Online-Host: wap.baidu.com
After such a request arrives at the mobile gateway, it will be mistakenly sent to http://wap.baidu.com/uc.png. But what we actually want to request is a http://wap.baidu.com/logo.gif (? Variable ).
Because the mobile gateway is actually an HTTP proxy server, which processes the X-Online-host protocol as follows:
Intercept the URL field in the Request Header:
If no http: // field exists, the field is used as the relative Uri, which is supplemented with the X-Online-Host field;
If an http: // field exists, use this field as the absolute Uri and replace the host with the X-Online-host value.