Friday, September 05, 2008

测试手机的 User-Agent

由于最近工作中需要得到一些手机的 User-Agent 以及 X-Wap-Profile 两个 HTTP 头的值,于是写了个简单的 PHP 程序,检测 HTTP 头,输出到 Response,然后放到网站上,让手机用 WAP 浏览器打开查看。

开始这个程序只是简单的输出纯文本,结果是 NOKIA、Sony Ericsson 以及 Samsung 手机都能正确读出,而 Motorola 却不行(实际测试过程中用的是 Motorola RAZR V3i),仅显示白页。

后来把程序改成输出标准 WML 页面,HTTP 头的 Content-Type 设置成 application/vnd.wap.xhtml+xml,NOKIA、Sony Ericsson 以及 Samsung 仍然能够正确显示而 Motorola 还是不合作。

最后找到答案,Content-Type 要设置成“text/vnd.wap.wml”,这下 Motorola 终于老实了…… 可是结果中只有 User-Agent,没有 X-Wap-Profile。

另外,在用中国移动的 SIM 卡测试的时候,发现 HTTP 请求中并没有 User-Agent 和 X-Wap-Profile 这两个头,而有个奇怪的
VIA: HTTP/1.1 SCCD-PS-WAP-GW02 (infoX-WISG, Huawei Technologies)
开始以为是手机的问题,但看到“Huawei”字样,觉得很蹊跷,后来换成 Orange France 的 SIM 卡,则一切正常了。

看来拦截 HTTP 请求是中国运营商的“优良传统”啊!

Update 2009/08/03:

最近发现中国移动这个问题只存在于 cmwap,用 cmnet 则正常。

5 comments:

Maple said...

太有才了,以一个局外人的角度来看您太有才了,非常感谢

Black-Xstar said...

万恶的cmwap啊……

Anonymous said...

Wonderful blog! Do you have any recommendations for aspiring writers?

I'm planning to start my own site soon but I'm a little
lost on everything. Would you advise starting with a free platform like Wordpress or
go for a paid option? There are so many choices out there that I'm completely overwhelmed ..
Any recommendations? Bless you!

My web site Chemist Direct Healthcare Products

Unknown said...

louis vuitton handbags
burberry scarf
ray ban sunglasses outlet
michael kors
cheap uggs
cheap oakleys
abercrombie fitch
ugg boots
tory burch flats
lv outlet
tods outlet
michael kors handbags
michael kors outlet online
ghd flat iron
coach outlet
coach factory online
prada handbags
lebron 11
canada goose jacket
ray ban outlet
christian louboutin
chanel handbags
coach outlet
polo outlet
michael kors outlet online
ray ban canada
coach factory outlet
20150311huangqihang

Unknown said...

Cheap Nike Air Max new jordans lebron james shoes 2016 Nike Air Max jordans for sale Cheap Jordans cheap kd shoes Nike Outlet cheap nike basketball shoes jordan shoes kobe basketball shoes Nike free Run Cheap Jordans for sale cheap jordan shoes jordans 2016 Nike Air Max 2016 nike basketball shoes 2016 Nike Store nike basketball shoes 2016 louboutin shoes mizuno shoes red bottom shoes for women red bottoms shoes red bottoms shoes on sale mizuno wave red bottom shoes christian louboutin christian louboutin outlet louboutin sale