PDA

View Full Version : Why the server know the request is from android phone?



firefly3
09-25-2011, 04:43 AM
hi guys,

i have a question about how the web server know the http request is from an android phone but not pc browser. anyone know? for example, if we browse some particular website, the server will return a mobile format of website to our android phone. I would like to know that how this thing happen. if ok, please explain it in a programming view.

Thanks. :android-dance: Good days all!

dreded
10-05-2011, 12:49 PM
User Agent String
From a web developers perspective, if I wanted to create different pages for people viewing with browsers (IE, Mozilla, Safari) in order to ensure I'm providing a website that abides by their web standards (yes they're different), I can use the User Agent String passed from the browser to the server to determine browsing engine and operating system.


Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405

User Agent Sniffing is the practice of gaining this information to display information based on end user device/browsers. Some methods are as simple as using META tags in your header to render WML to mobile browsers, while other methods use JavaScript and other languages to determine this information.