Find HTTP Request Source – Computer, Mobile Phones or Tablets ?

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 .
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.
3. Client Side (Using Javascript) –
If you are interested in writing client side code for detecting the request source then don’t worry MobileESP also provides solution for that. This javascript solution is recommended for tasks that are lighter in nature means it shouldn’t impact the overall application performance .If your requirement is on the higher end and you want to use these APIs extensively upto granular level then it is recommended that you should use the Sever Side APIs. For javascript the file that you can use is mdetect.js and it can be found here.

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.

String userAgent=request.getHeader(“User-Agent”);

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.


Saurabh Jain

A Developer working on Enterprise applications ,Distributed Systems, Hadoop and BigData.This blog is about my experience working mostly on Java technologies ,NoSQL ,git , maven and Hadoop ecosystem.

One thought on “Find HTTP Request Source – Computer, Mobile Phones or Tablets ?

Add Comment Register

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>