处理http头,格式化输出
Posted 吴云龙
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了处理http头,格式化输出相关的知识,希望对你有一定的参考价值。
<html> <head> <script> function insertStr(str1,n,str2){ if(str1.length<n){ return str1+str2; }else{ s1 = str1.substring(0,n); s2 = str1.substring(n,str1.length); return s1+str2+s2; } } function searchd(key1,mod_rest) { var loc = mod_rest.search(key1); if(loc==-1){ return mod_rest; } else{ var mod_restd = insertStr(mod_rest,loc,"\n"); return mod_restd; } } function displayResult() { //打印post和get var testval = document.getElementById("myTextarea").value; var post_get = testval.split(" ",3); //alert(typeof post_get); var raw1 = post_get[0]+" "+post_get[1]+" "+post_get[2]; //剩下的以":" 为分隔符 //var rest = testval.split(":",5); //alert(typeof row1); //post_get.tostring(); rest = testval.replace(raw1,""); //alert(rest); t = searchd(/Accept:/,rest); //alert(t); t1 = searchd(/Accept-Encoding:/,t); t2 = searchd(/Host:/,t1); t3 = searchd(/Accept-Charset:/,t2); t4 = searchd(/Cookie:/,t3); t5 = searchd(/Connection:/,t4); t6 = searchd(/Cache-Control:/,t5); t7 = searchd(/User-Agent:/,t6); t8 = searchd(/Pragma:/,t7); t9 = searchd(/Acunetix-Aspect:/,t8); t10 = searchd(/Acunetix-Aspect-Password:/,t9); t11 = searchd(/Acunetix-Aspect-Queries:/,t10); t12 = searchd(/Content-Length:/,t11); t13 = searchd(/Content-Type:/,t12); t14 = searchd(/Accept-Language:/,t13); t15 = searchd(/Accept-Ranges:/,t14); t16 = searchd(/Authorization:/,t15); t17 = searchd(/Date:/,t16); t18 = searchd(/Expect:/,t17); t19 = searchd(/From:/,t18); t20 = searchd(/If-Match:/,t19); t21 = searchd(/If-Modified-Since:/,t20); t22 = searchd(/Max-Forwards:/,t21); t23 = searchd(/Proxy-Authorization:/,t22); t24 = searchd(/Range:/,t23); t25 = searchd(/Warning:/,t24); t26 = searchd(/Referer:/,t25); //alert(t26); document.getElementById(‘myexparea‘).value=raw1+t26; } </script> </head> <body> <textarea id="myTextarea" name="testt" cols="80" rows="30"> POST /maneinfo/login.asp HTTP/1.1 Pragma: no-cache Cache-Control: no-cache Referer: http://sbzxyey.jdjy.cn/ Content-Length: 48 Content-Type: application/x-www-form-urlencoded Acunetix-Aspect: enabled Acunetix-Aspect-Password: 082119f75623eb7abd7bf357698ff66c Acunetix-Aspect-Queries: filelist;aspectalerts Cookie: ASPSESSIONIDSSATAQRD=AOGJBOEBGCGIFPCFHEDNOCNH Host: sbzxyey.jdjy.cn Connection: Keep-alive Accept-Encoding: gzip,deflate User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.63 Safari/537.36 Accept: */* picnum=3943&pwhidden=&saveUser=&SecEx=&username= </textarea> <textarea id="myexparea" name="expio" cols="80" rows="30"> </textarea> <br> <button type="button" onclick="displayResult()">Alert value of text area</button> </body> </html>
以上是关于处理http头,格式化输出的主要内容,如果未能解决你的问题,请参考以下文章