HTTP POST模拟器

存入本地用IE打开可基本实现模拟任意数据POST的HTTP请求

<html>
         <head>
                   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                   <script type="text/javascript">
                   function gb2utf8(data)
                   {
                            var glbEncode = [];
                            gb2utf8_data = data;
                            execScript("gb2utf8_data = MidB(gb2utf8_data, 1)", "VBScript");
                            var t = escape(gb2utf8_data).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
                            t = t.split("@");
                            var i = 0, j = t.length, k;
                            while( ++i < j )
                            {
                                     k = t[i].substring(0,4);
                                     if(!glbEncode[k])
                                     {
                                               gb2utf8_char = eval("0x"+k);
                                               execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript");
                                               glbEncode[k] = escape(gb2utf8_char).substring(1,6);
                                     }
                                     t[i] = glbEncode[k]+t[i].substring(4);
                            }
                            gb2utf8_data = gb2utf8_char = null;
                            return unescape(t.join("%"));
                   }
                   window.onload=function(){
                            document.getElementById("send").onclick=function(){
                                     document.getElementById("result").innerText="Loading...";
 
                                     var xhr = new XMLHttpRequest();
                                     xhr.open("POST", document.getElementById("url").value);
                                     xhr.setRequestHeader("Content-Type","application/x-www-form-encoded");
                                     xhr.onreadystatechange=function(){
                                               if(xhr.readyState==4)
                                               {
                                                        document.getElementById("result").innerHTML=xhr.responseText;
                                               }
                                     }
                                     xhr.send(document.getElementById("postData").value);
                            }
                            document.getElementById("decode").onclick=function(){
                                     document.getElementById("result").innerText=gb2utf8(document.getElementById("result").innerText);
                            }
                   }
                   </script>
                   <style>
                            body{
                                     font-family:'Courier New';
                                     font-size:12px;
                                     text-align:center;
                            }
                            #form{
                                     width:600px;
                            }
                            #url{
                                     width:500px;
                            }
                            #send{
                                     width:90px;
                            }
                            #postData{
                                     width:600px;
                                     height:300px;
                            }
                            #result{
                                     text-align:left;
                                     white-space:nowrap;
                                     width:600px;
                                     border:1px solid black;
                                     overflow:auto;
                            }
                   </style>
         </head>
         <body>
                   <div>
                            <div id="form">
                                     <input id="url" type="text" value="" />
                                     <input id="send" type="button" value="send" />
                                     <input id="decode" type="button" value="decode" />
                                     <textarea id="postData"></textarea>
                            </div>
                            <div id="result"></div>
                   </div>
         </body>
</html>