Rajen M. Parekh wrote:
Nope. So, my question is still is that if changing the UA string in Mozilla/Firefox works with Windows, then why does not it work with Linux ?
It worked out for me on Linux as well after changing the UA to IE 6. I don't know why it didnt work at your place.
How is the web site able to know which OS is running in the background when the UA strings defines the OS to be Windows ? There has to be some way by which it is able to know this. I am not strong on networking / http technicals, but there would be some way to find out what information is exchanged between the server and client (Mozilla in our case).
When a Client makes a request to the webserver, some environment variables are passed and these are common for all the WebServers regardless of Linux based servers or windows based server. The exact names may differ between servers however the information remains the same.
Incase of CGI environment these variables are SERVER_NAME, REMOTE_HOST, REMOTE_ADDR, PATH_INFO, HTTP_USER_AGENT|||||| etc. Check this link for a list of complete set and who sets values for them. (http://hoohoo.ncsa.uiuc.edu/cgi/env.html)
The requesting client's hostname and IP address can be determined by the values of REMOTE_HOST and REMOTE_ADDR where as the browser he is using and the OS can be determined using HTTP_USER_AGENT. I remember in my days of ASP programming these variables were something like http_referrer and stuffs like that, I don't recollect properly.||
You write a simple cgi script and get these values as
my $server = $ENV{'SERVER_NAME'}; my $agent = $ENV{'HTTP_USER_AGENT'};
then further ....... if($agent =~ 'windows') { stuff for windows ............. }elsif($agent =~ 'linux'){ stuff for linux ......... }else{ stuff for others ......... }
pretty simple. I wrote a similar CGI script some time back that determined Windows version from the request and generated the approriate Registry file for download.
To see how the actual string goes to the server (e.g. Apache) you can startup your HTTPD webserver on your machine and try to access http://localhost/ from your browser and see the /var/log/httpd/access_log file for the string.