zoukankan      html  css  js  c++  java
  • DAY6 处理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,"
    ");
                    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>
  • 相关阅读:
    第13周学习进度情况
    【Android进阶】获取Android软件的版本信息
    【Android进阶】Android程序与JavaScript之间的简单调用
    字符串长度
    约瑟夫问题
    输入n个数和输出调整后的n个数
    输入三个整数,按由小到大的顺序输出
    学校oj平台上不去
    输入10个整数
    输入三个字符串,按由小到大的顺序输出
  • 原文地址:https://www.cnblogs.com/lt132024/p/5565074.html
Copyright © 2011-2022 走看看