In this post we are going to see 6 different ways by which we can find HTTP request source .
These days whenever we develop an application , our target is that it should be accessible from both computers and mobile devices so that an end-user can access the application wherever he wants and whenever he wants. So, when we target audience from the both these channels there is always a challenge that exist for a developer to identify a request source whether it is coming from a computer , mobile device or tablet . I am saying this as a challenge only on the basis of request source content will be rendered on the user system whether its computer, mobile device or a tablet by applying the different resolution policy , css , scripts anything that will execute on client side. Even after this there is one more challenge to find out the device type whether its Android ,Apple , Black Berry or Windows.
From here we will see all the ways by which we can find HTTP request source .So, for this now you have two options either you can handle this thing on Server Side Code or Client Side Code, we will see solutions on both side.
1. Server Side (Using Java) –
If you want to handle this thing on server-side then you can use the following class UAgentInfo.java .
It is an open source project developed by MobileESP and it provides you very granular level details of each and every type even more latest operating system one like Tigen ,Meego and Windows 8. For more reference you can visit here.
2. Server Side (Using PHP) –
If PHP is your cup of tea and you want to handle this on server side only then MobileESP also provides you API for that. Here you will have a server file mdetect.php that you can use internally in your application for identifying source of request. You can find the file here.
It also covers all the device type , operating system types that its counter part java class supports.
Same server side APIs are also available for ASP.NET and python. You can follow the links here ASP.NET and Python.
4. One very basic solution that comes into mind of every java developer is to get from the HTTPServletRequest , generally user-agent header contains all this information that are required for identifying the request source.
You can find the list of all the possible user agents and their corresponding browser here.
5. WURFL API (Wireless Universal Resource File):
If you are interested in going much more detail then WURFL API is the answer for you.Today almost all the market leaders like Facebook, Amazon, Google , Paypal all of them are using WURFL API for detecting the source of request. You can find more information here.
6. Tera-WURFL –
Tera-WURFL is developed over the WURFL platform and internally using the WURFL services for getting the device details by passing the user-agent information. As per wiki Tera-WURFL is faster in comparison to WURFL as it uses MySQL database i.e very light in comparison to other databases and use PHP for caching so that next time when the request came,result can be extracted much faster.
This post only explained about all the options that are available to us for detection a request source. I am planning to write one more post in which we will see the working of WURFL and Tera-WURFL.
Please share your thoughts and comments on same or If I have missed out any of them , feel free to add them.
Latest posts by Saurabh Jain (see all)
- java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskInputOutputContext, but class was expected - August 8, 2014
- org.datanucleus.store.rdbms.exceptions.MappedDatastoreException: INSERT INTO “TABLE_PARAMS” – Hive with Kite Morphlines - July 17, 2014
- java.io.IOException: can not read class parquet.format.PageHeader: null – Hive - July 12, 2014