Is Blackberry User-Agent only sent via browser?

大城市里の小女人 提交于 2019-12-11 07:49:30

问题


I would like to ask wheter the User-Agent property in the HTTP request header only sent via browser?

When I send a http/https request from a blackberry application, it seems there is no user-agent contains in the http header.

Thanks very much!

Also, if it is not possible to get the user agent from the request, are we able to get the user agent from Blackberry device?

Thanks!


回答1:


No, User-Agent is not sent automatically if you use javax.microedition.io.HttpConnection from within your application.

Instead, use

 HttpConnection con = (HttpConnection)Connector.open(myURL, 
                                         Connector.READ_WRITE, true);

con.setRequestProperty(HttpProtocolConstants.HEADER_USER_AGENT, "MyBlackberryApplication/1.0"); ... If you need information about the device to send along the agent string, all of it (OS version, device etc.) is accessible via BlackBerry API: look at this class: net.rim.device.api.system.DeviceInfo




回答2:


For unsigned j2me applications you can't set the user-agent and it will always be UNTRUSTED/1.0

http://www.j2megame.org/j2meapi/JSR_271_Mobile_Information_Device_Profile_3_0/javax/microedition/io/package-summary.html

This behavior for the Unidentified domain applications is specified in the Mobile Service Architecture (JSR 248) specification




回答3:


Yes, according to the Java document (javax.microedition.io ), it seems that user-agent is not automatically included unless you set it.

The application is responsible for formatting and requesting that the User-Agent field be included in HTTP requests via the setRequestProperty method in the interface

http://www.j2megame.org/j2meapi/JSR_271_Mobile_Information_Device_Profile_3_0/javax/microedition/io/package-summary.html



来源:https://stackoverflow.com/questions/6366265/is-blackberry-user-agent-only-sent-via-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!