#set $Response.ContentType = "text/html"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>
Test XMLHtpRequest
</title>
</head>
<body>
<a href="../Admin/melatijunit/Proxy?http://google.com">google</a>
<a href="javascript:checkUrl('HEAD','http://pizey.net/~timp/index.html');">check</a>
<a href="javascript:checkUrl('GET','http://pizey.net/~timp/index.html');">Get</a>
<a href="javascript:checkUrl('HEAD','http://pizey.net/~timp/index.htmlf');">404</a>

<div id="scribble" style="border:1px solid red; width:auto;"></div>

<script type="text/javascript">
 function checkUrl(method,url) { 
  var xmlHttpClient=false;
  if (typeof XMLHttpRequest!='undefined') {
    try {
        xmlHttpClient = new XMLHttpRequest();
    } catch (e) {
        xmlHttpClient=false;
    }
  }
  if (!xmlHttpClient && window.createRequest) {
    try {
        xmlHttpClient = window.createRequest();
    } catch (e) {
        xmlHttpClient=false;
    }
  }

  if (xmlHttpClient) { 
    try{ 
      xmlHttpClient.open(method, "../Admin/melatijunit/Proxy?"+url,true);
      xmlHttpClient.onreadystatechange =  function() {
        if(xmlHttpClient.readyState == 4) {
          alert("ALL:" + this.getAllResponseHeaders());
          alert("ct:" + this.getResponseHeader("Content-Type"));
          alert("st:" + this.status);
          if (method == "GET") {
            var scribble = document.getElementById("scribble");
            scribble.innerHTML = ":" + xmlHttpClient.responseText + ":";
          }
        }
       };
       xmlHttpClient.send(null);
       
       
     } catch (e) {
       alert(e);
     }
  } else {
    alert("XMLHttpRequest not available");  
  }
  return xmlHttpClient;
 }
</script>

</body>
</html>
