Whenever I hear about a new phone release I try to test my mobile sites with it, particularly if it carries a new browser like the T-Mobile G1, Blackberry Storm or the Polaris browser found on the Helio Drift and Kickflip. I have no budget for test handsets so I test with the demo phones in carrier owned mobile shops. When I find an issue in testing I capture the phone’s User-Agent string so I can modify my browser detection and adaptation code to handle it properly. There are mobile pages that can display the headers on the phone’s screen. I used to use one of these sites and write the User-Agent down in a notebook, but that’s a bit laborious and very error prone. So I came up with a little script that displays the User-Agent and several other “interesting” headers on the screen and offers the option to email them.
Knowing your phone’s user agent isn’t only useful to developers. There are a number of mobile phones and mobile operators that block OTA downloads of games, applications, ring tones, themes and wallpapers. This is true of Nextel, Boost, Verizon and Virgin Mobile in the US.
In many cases it’s possible get about these restrictions using a cable or BlueTooth to side-load the content on your phone. On Verizon phones, the only off-portal way to load ring tones is by sending them in an MMS. Before you can do any of these things you have to get the files on your PC. Usually this pretty easy. But some software and content vendors only allow downloading OTA to your phone and they check the phone’s User-Agent to deliver the correct version, or no version at all it the phone is unsupported or you are using a PC web browser. There is a work around. A Firefox extension called User Agent Switcher lets you temporarily change the browser’s User-Agent to anything you want. Once you have your phone’s User-Agent you can impersonate it with User Agent switcher and download the files you need.
Besides the User-Agent, my script also reports the Accept, Accept-Encoding, Accept-Language and Accept-Charset headers as well as the Via header and any “X” headers. The Via and X headers can be used to identify transcoders. Many browsers send an x-wap-profile header which contains the URL of a UAProf file describing the device’s characteristics.
Here are a couple examples of the script’s output:
This is what my N95’s built in WebKit Browser sends:
user-agent: Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95-3/20.2.011; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413
accept: text/html,text/css,multipart/mixed,application/java-archive, application/java, application/x-java-archive, text/vnd.sun.j2me.app-descriptor, application/vnd.oma.drm.message, application/vnd.oma.drm.content, application/vnd.oma.dd+xml, application/vnd.oma.drm.rights+xml, application/vnd.oma.drm.rights+wbxml, application/x-nokia-widget, */*
accept-language: en-us, en;q=1.0,fr-ca, fr;q=0.5,pt-br, pt;q=0.5,es;q=0.5
accept-charset: iso-8859-1, utf-8; q=0.7, *; q=0.7
accept-encoding: gzip, deflate, x-gzip, identity; q=0.9
These are the headers sent by the same phone using Opera Mini:
user-agent: Opera/9.50 (J2ME/MIDP; Opera Mini/4.2.13216/428; U; en)
accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
accept-charset: iso-8859-1, utf-8, utf-16, *;q=0.1
accept-encoding: deflate, gzip, x-gzip, identity, *;q=0
x_operamini_features: advanced, file_system, folding
x_operamini_phone: Nokia # N95
x_operamini_phone_ua: Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95-3/20.2.011; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413
Spammers love to use email scripts like this one to send junk to everyone’s mailbox. I’ve added a lot of safeguards and input checking to the script try and prevent its misuse. If I find it’s being used to send spam I’ll have to take it down, of course. It’s also possible that my anti-spammer code will cause the script to fail on phones that send some really weird headers. If you get an error message saying something about a “Suspected injection attempt”, “invalid email address” or “newline found” please let me know via a comment on this post or by using the Contact Form. Please include the name of your carrier and phone and, if possible, the full text of the error message.
If your are worried about providing your email address, I don’t store email addresses and will never share yours with anyone. If you want to be extra safe, use a disposable email address from a free service like Spamgourmet.com or Yahoo Mail’s Addressguard.