免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5660 | 回复: 2
打印 上一主题 下一主题

悬赏:登入apache显示header错误,烦牛人指点一下 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-08-19 18:38 |只看该作者 |倒序浏览
5可用积分
浏览器访问apache时出现下面的错误,perl代码见下方,哪位达人帮忙看看,谢谢。

[wls81@cnsz040318 f5httpconsole]$ tail -f error.20130819.log
[Mon Aug 19 14:21:31 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 14:21:38 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 14:22:22 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 14:35:31 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 18:17:22 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 18:17:37 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 18:17:46 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 18:27:21 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 18:27:23 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 18:27:24 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 18:28:49 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
^[[A[Mon Aug 19 18:33:18 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login
[Mon Aug 19 18:33:35 2013] [error] [client 10.13.44.176] malformed header from script. Bad header=\xc1\xac\xbd\xd3\xca\xa7\xb0\xdc: f5login


perl代码如下:

[wls81@cnsz040318 cgi-bin]$ vi f5login
#!/usr/bin/perlnew
use lib ('/wls/apache/appsystems/admconsole/lib/');
#use strict;
use warnings;
use File::Basename;
use CGI qw(:standard);
use Cwd 'abs_path';
use HttpMan;
use CommonConfig;
use Data:umper;
use LWP::UserAgent;
use Crypt::SSLeay;
use HTTP::Cookies;
use Utils;
use IO::File;

my $host=param('host');
my $url = 'https://$host/tmui/login.jsp';
# 获得COOKIE
my $cookie_file = "/tmp/lwp_cookies.txt";
my $cookie_jar = HTTP::Cookies->new(file => $cookie_file,autosave => 1,ignore_discard => 1);
  my $ua = LWP::UserAgent->new;
        $ua->ssl_opts(verify_hostname=>0);
        $ua->cookie_jar($cookie_jar);
        $ua->timeout( 15 );
  my $response = $ua->get( $url );
  my $cookie;
  if ( $response->is_success ) {
        my $cookie_jar = HTTP::Cookies->new;
        $cookie_jar->extract_cookies($response);
     $cookie_temp = $cookie_jar->as_string();
}
       my $header = HTTP::Headers->new();
          $header->header('Accept'               => 'image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*');
           $header->header('Referer'              => "https://$host/tmui/login.jsp";
           $header->header('Accept-Language'      =>'zh-CN');
           $header->header('User-Agent'           =>'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)');
           $header->header('Content-Type'         =>'application/x-www-form-urlencoded');
           $header->header('Accept-Encoding'      =>'gzip, deflate');
           $header->header('Host'                 => $host);
           $header->header('Content-Length'       =>'29');
           $header->header('Connection'           =>'Keep-Alive');
           $header->header('Cache-Control'        =>'no-cache');
           $header->header('Cookie'               => $cookie_temp);
my $post_data = 'username=admin&passwd=Ig5Fbi9';
my $request = HTTP::Request->new('POST', $url,$header,$post_data);
       my $response1 = $ua->request($request);
        if($response1 -> is_success){
        my $hh = $response1 -> headers_as_string;
        #$hh=~s/^Client-SSL-.*\s+//igm;
        print( "Content-Type: text/html\r\n" );
        print('Status:' .$response1->status_line ."\r\n";
        print("Set-Cookie:BACK_END_HOST=$hostATH=/\r\n";
        print("Set-Cookie:type=f5; PATH=/\r\n";
        print "$hh";
        print("\r\n\r\n";
        print $response1->content;
        print "连接成功\n";
       # print $response1 -> as_string() . "\n";
        }else{
           print "连接失败\n";
        }

论坛徽章:
0
2 [报告]
发表于 2013-08-19 20:14 |只看该作者
这个问题已经解决了,谢谢大家。
perl输出有一个错误导致返回浏览器的header中第一行不是标准的输出格式。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP