One Useful Infinite Loop

Posted by Jessica Tue, 29 Jan 2008 01:49:00 GMT

If you are ever are in need of a page that would keep a url connection open for an extended period of time, as opposed to simply returned a 404 or 500 error, then you might consider simulating an unresponsive page by creating a page with an infinite loop on it.

<html>
<script>
   function infiniteLoop() {
   var i = 0;

   while (i<=0)
   {
     i = i-1;
   }
}
</script>
<body onload="infiniteLoop()">
</body>
</html>

Ok, so javascript won’t work (that is, you should get a 200 from this page) because it is on the client side, but do the same thing with a jsp or embedded ruby.

<html>
<body>
<% int i = 0;
while (i<=0) {
  i--;
}
%>
</body>
</html>

This is nice for testing timeout parameters on an http connection that you have opened up. For instance, using the java library HttpClient, you can set the connection timeout on a connection. Instead of attempting to connect with the availabe resource, try to connection to this infinite loop page.

Trackbacks

Use the following link to trackback from your own site:
/blog/articles/trackback/12734

Comments

Leave a response

Comments


designed by jowensbysandifer