Thursday, January 11, 2007

Welcome to the launch of IIIT LAN Browser 1.0 and FuckProxy 0.2

So all my readers( thats only me, I guess :P But isn't this blog meant for me only?) , I did some good work in this winter vacation. I released FuckProxy 0.2, the upgrade for the old 0.1 and made a new firefox extension IIIT LAN Browser. See my post here that kind of advertises it :D

This is the change log for FuckProxy 0.2:
1. Fixed a few bugs.
2. Added better support for ftp.
3. Added auto-update feaure.
4. Changed the position of FP Button as the previous position was interfering with the toolbars of delicious,etc.
5. Now typing "http" in the address bar is not a compulsion.

IIIT LAN Browser is an extension for the LAN Browser CGI proxy I had earlier. It provides the same functionality but much more easier to use now. Apart from that its much much more robust. The earlier version used to throw errors on half of the sites because of bad parsing. But this one does not parses at all. It directly uses the DOM Tree generated by firefox! So no problem at all. I guess no CGI proxy in world would have as robust parsing as this one.(Well if I dont't parse at all and use Firefox's work, then obviously it will be robust :P ).
I also added login functionality so that only iiitians can use it. You need to enter your 200 login and password to use it. Have fun...

PS: I have been always saying "PHP sucks, Python rocks". But looks like its not so true. However good python may be, but when it comes to making sites, PHP has the greatest no. of functionalities available. Python does not even have basic Session support!

How to refresh a page that is not loaded?

First of let us understand the heading of my post ;) If a page is already loaded in the browser, there are several methods to refresh it. You will find them all over the internet.
For example, you can use:-

  1. <equiv="refresh" content="5">
  2. location.reload(true)
  3. javascript:history.go(0)
  4. etc.
However, consider a different scenario. I typed the url of a page "A" that requires login. Now the page will redirect you to the login page "B". After you login successfully, you will again be redirected to the actual page that you requested, that is page A. Now your browser knows from its cache, that when you earlier requested page A, it was redirected to page B. So it will now not send a request for page A to server. It will directly load the contents of page B instead! Now browser is doing correct by trying to save network bandwidth and by trying to reduce server load. But in our case its a problem.
Now you will ask this scenario happens in most of the sites and they all work perfectly fine. The reason is that in most of the sites, when they redirect you after successful login, to page A, they change the url of A a little bit. That is mostly you will find that after you login, there will be some sid, or username appended to the url. That concatenation makes this url not same a A and so browser loads it all over again and the site seems to be working fine.(though the site maker has no idea about all this and was just lucky).
But I have a site where the url of page A does not changes. There are some restrictions and the url of Page A has to remain exactly same. So how do I solve the problem? I searched all over net but couldn't find.(though there must be some solution). But right now I am using this method:-

<html>
<body onLoad="document.form1.submit();" >
Login successful. You are being redirected to the page requested by you.
<form method="post" action="URL of the page to redirect to" name="form1">
</form>
</body>
</html>

Note that the above thing will ask the browser to use POST method. And browser knows that pages fetched with POST method are dynamic and it can't rely on cache. So it won't rely on cache and ask a copy of the page again from the server. Thats it.

PS: Even if the urls are same, browser will sometimes fetch the new copy from the server. This is just my observation. Because in my lab, I had no problem with the simple redirection. But I found that at few other places the cache copy was being used. So I had to use the post method. I guess this all depends on browser settings and proxy settings.

PS: The above problem happened with me with my IIIT LAN Browser project.

Tuesday, January 09, 2007

Shell : Its simply awesome man!

Linux lovers please don't start patting your back, because the Shell in consideration here is not the Unix shell but the shell javascript bookmarklet developed by Jesse Ruderman. Man it gives you so much insight into the webpage. You can see the total DOM structure. Though DOM Inspector does the same, but its much more easier to use the command line. And the DOM Inspector won't allow you execute commands,etc. In shell you can live edit your page.
Remember, many times you write a page with a little javascript in a console and then test it in a browser to see if your functions are working or not. Many times you don't even know whether a function exists or not. You use it and then run in browser to see if it works or not. Many times you don't know how a particular function behaves. Man this all can be done very easily in this shell.

For me the best part is :
I am new to the javascript and DOM,etc. When I code something I don't know which function would work correctly here. So I code with a lot of assumptions in my mind, and then finally when I don't see the expected results I have a tough time debugging it. This shell will now help me in this area.
I am sure if I had known about it before I made the FuckProxy and IIIT LAN Browser extensions, then I would have made them in a much more better and efficient way. And in much less time also.
Thank You Jesse Ruderman!

Friday, January 05, 2007

FuckProxy Update

FuckProxy has been updated to work with latest firefox version 2.0.0.1.
I have kept the old version number, so in order to install it, please uninstall the previous version first.
I am thinking of enabling the auto-update option so that firefox automatically looks for updates as it does for other extensions. But that will take time.
Also FuckProxy has been disabled for requests that are from outside IIIT intranet. This has been done to prevent possible misuse of IIIT resources.

Enjoy!!