我如何得到HTTP_USER_AGENT真正的设备? 当我使用的WebView,我能得到真正的价值是这样的:
How do I get the real device in http_user_agent? When I use a WebView, I can get the real value like this:
[HTTP_USER_AGENT] => Mozilla/5.0(Linux; U; Android 2.2; en-gb; LG-P500 Build/FRF91)
AppleWebKit/533.0 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
但是,当我使用Apache连接,其结果是不同的:
But when I use an Apache connection, the result is different:
[HTTP_USER_AGENT] => Apache-HttpClient/UNAVAILABLE(java 1.4).
这是什么问题?
What's the problem?
如果你不想叫 SetHeader可以()
为每个请求创建可以设置HTTP客户端参数 CoreProtocolPNames.USER_AGENT
。这样做HTTP客户端后,将这个头参数自动添加到每个请求。
If you don't want to call setHeader()
for every request you create you can set the http client parameter CoreProtocolPNames.USER_AGENT
. After doing this HTTP client will automatically add this header parameter to each request.
是这样的:
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Custom user agent");
当你创建你的的HttpClient
。