登陆;http://192.168.32.161/DEVOPS/index.php/Index/do_login

Cache-Control	no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection Keep-Alive
Content-Encoding gzip
Content-Length 23
Content-Type text/html; charset=UTF-8
Date Fri, 23 Sep 2016 14:16:49 GMT
Expires Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive timeout=5, max=95
Location /DEVOPS/index.php/Main/index
Pragma no-cache
Server Apache/2.2.31 (Unix) PHP/5.6.20
Vary Accept-Encoding
X-Powered-By PHP/5.6.20 function do_login(){
//获取用户名和密码信息,和数据库中比对
// echo 111111111;
// dump($_POST);
// dump($_SESSION);
$username=$_POST['username'];
$password=$_POST['password'];
$code=$_POST['code'];
if($_SESSION['verify']!==md5($code)){
$this->error('验证码错误');
} $m=new Model('user');
$where['username']=$username;
$where['password']=md5($password); $arr = $m->where($where)->find(); $i=$m->where($where)->count(); if ($i>0){
$_SESSION['username']=$username;
$_SESSION['authority'] = $arr['authority'];
$this->redirect('Main/index');
}else{
$this->error('该用户不存在');
}
} 登陆成功后跳转到Main/index页面 http://192.168.32.161/DEVOPS/index.php/Main/index use Net::SMTP;
use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Headers;
use HTTP::Response;
use Encode;
use Switch;
use File::Temp qw/tempfile/;
use HTTP::Date qw(time2iso str2time time2iso time2isoz);
my $CurrTime = time2iso( time() );
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $now = time();
$ua->agent('Mozilla/5.0');
my $cookie_jar = HTTP::Cookies->new( file => 'lwp_cookies.txt',
autosave => 1,
ignore_discard => 1
);
$ua->cookie_jar($cookie_jar); my $response = $ua->get("http://192.168.32.161/DEVOPS/index.php/Public/code" );
if ( $response->is_success ) {
$r = $response->decoded_content; # print $response->decoded_content; # or whatever
}
else {
die $response->status_line;
};
my ( $fh, $filename ) =
tempfile( "wj_qrcode_XXXX", SUFFIX => ".jpg", DIR => 'c:\\' );
binmode $fh;
print $fh $r;
close $fh;
print "登录二维码已经下载到本地 [ $filename ] \n"; ##打开图片
system("start $filename "); my $validCode = <STDIN>;
chomp $validCode;
print "\$validCode is $validCode\n";
my $login_url =
'http://192.168.32.161/DEVOPS/index.php/Index/do_login'; my $res = $ua->post(
$login_url,
{ 'username' => 'admin', 'password' => 'admin',
'code' => "$validCode"
}
);
print "---------------\n"; ##判断响应头里面的location,确定是否登陆成功
my $content = $res->as_string() ;
my $content = encode( "gbk", decode( "utf8", "$content" ) );
print "\$content is $content\n";
#获取的是原始内容,包括响应头,响应正文 print $res->header('Location'); 返回;
F:\>perl php.pl
登录二维码已经下载到本地 [ C:\wj_qrcode_kz0X.jpg ]
9017
$validCode is 9017
---------------
$content is HTTP/1.1 302 Found
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection: close
Date: Fri, 23 Sep 2016 14:42:17 GMT
Pragma: no-cache
Location: /DEVOPS/index.php/Main/index
Server: Apache/2.2.31 (Unix) PHP/5.6.20
Vary: Accept-Encoding
Content-Length: 3
Content-Type: text/html; charset=UTF-8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Client-Date: Fri, 23 Sep 2016 14:45:09 GMT
Client-Peer: 192.168.32.161:80
Client-Response-Num: 1
X-Powered-By: PHP/5.6.20 /DEVOPS/index.php/Main/index

响应头location 页面跳转的更多相关文章

  1. regexp模式匹配+location页面跳转+cookie/localstorage本地存储

    学习js的过程中,根据知识点编写一些code进行测试,以便检验. 这段程序使用了以下知识点: 1.regexp,对数据进行模式匹配 2.使用location对象进行页面跳转. 3.cookie/loc ...

  2. nginx替换响应头(重点:如何在替换时加上if判断)

    在实现微信小程序内嵌非业务域名时,通过nginx做镜像网站绕过小程序业务域名检测,但有一些表单页面提交后会返回一个302状态,由响应头Location的值决定提交成功后的跳转地址.那么问题来了,这个地 ...

  3. HTTP请求头和响应头

      这篇文章简单总结一下HTTP请求头和响应头,并举一些web开发中响应头的用例. 1. HTTP请求头 accept:浏览器通过这个头告诉服务器,它所支持的数据类型.如:text/html, ima ...

  4. javaweb(四)——Http协议(请求头,响应头详解)

    一.什么是HTTP协议 HTTP是hypertext transfer protocol(超文本传输协议)的简写,它是TCP/IP协议的一个应用层协议,用于定义WEB浏览器与WEB服务器之间交换数据的 ...

  5. Http协议请求头、响应头、响应码

    Http部分请求头 Accept 客户机通过这个头,告诉服务器,它支持哪些数据类型 Accept-Charset 客户机通过这个头,告诉服务器,它支持的编码 Accept-Encoding 客户机通过 ...

  6. JavaWeb学习记录(一)——response响应头之缓存设置与下载功能的实现

    一.HTTP中常用响应头 Location: http://www.it315.org/index.jsp Server:apache tomcat Content-Encoding: gzip Co ...

  7. 通过refresh响应头,定时刷新或隔n秒跳转页面

    package day08; import java.io.IOException; import javax.servlet.ServletException; import javax.servl ...

  8. http 响应头之location

    <pre name="code" class="html">jrhmpt01:/root# cat login_yylc.pl use LWP::U ...

  9. window.location.hash 页面跳转,精确定位,实例展示:

    window.location.hash 页面跳转,精确定位,实例展示: (1).index.phtml,页面用于传参 <script id="bb_list_template&quo ...

随机推荐

  1. navicat 随笔提示的快捷键

    1.ctrl+q 打开查询窗口2.ctrl+/ 注释sql语句3.ctrl+shift +/ 解除注释4.ctrl+r 运行查询窗口的sql语句5.ctrl+shift+r 只运行选中的sql语句6. ...

  2. Hadoop2.4.1 MapReduce通过Map端shuffle(Combiner)完成数据去重

    package com.bank.service; import java.io.IOException; import org.apache.hadoop.conf.Configuration;im ...

  3. (转)利用ant在Mac 下自动化打包签名Android程序

    1.创建一个android项目 参数说明:-k /--package 为命名空间(包名)-a /--name 工程名-p /--path 项目 -t 为目标平台的版本编号 命令:./android c ...

  4. kvm cobbler无人值守批量安装操作系统

    kvm cobbler无人值守批量安装操作系统 cobbler:一个自动网络安装系统的工具,集成PEX.dhcp.dns.tftpd.sync等服务.可以供大家管理安装操作系统 kvm:Linux系统 ...

  5. nginx 配置正向 HTTP 代理服务器[转]

    如果不想写到 ngnix.conf 中,那么可以在相同的目录下建立另外一个文件夹存放单独的文件,比如新建一个  proxy 的子目录,然后再在里面新建文件 prox.conf ,然后添加如下内容: s ...

  6. 一步一步教你做ios推送

    最近在研究ios的推送问题,遇到了一些问题,最终整理了一下.放在这里和大家分享 APNS的推送机制 首先我们看一下苹果官方给出的对ios推送机制的解释.如下图 Provider就是我们自己程序的后台服 ...

  7. hdu 4848 搜索+剪枝 2014西安邀请赛

    http://acm.hdu.edu.cn/showproblem.php?pid=4848 比赛的时候我甚至没看这道题,事实上不难.... 可是说实话,如今对题意还是理解不太好...... 犯的错误 ...

  8. Swift中实现点击、双击、捏、旋转、拖动、划动、长按手势的类和方法介绍

    1.UITapGestureRecognizer 点击/双击手势 代码如下: var tapGesture = UITapGestureRecognizer(target: self, action: ...

  9. 使用CXF+spring创建一个web的接口项目

    一.web project整合spring 1.1.打开Myeclipse,建立web project(eclipse为dynamic web project),使用J2EE5.0. 1.2.加入Sr ...

  10. html+jq实现简单的图片轮播

    今天上班没事,就自己琢磨着写一下图片轮播,可是没想到,哈哈竟然写出来啦,下面就贴出来代码,作为纪念保存下下哈: <body style="text-align: center;&quo ...