登陆;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. HDU_2034——集合A-B

    Problem Description 参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合的减法 ...

  2. 批量将文件转换为UTF-8无BOM格式

    最近有一个项目需要迁移,要把文件全部转换成utf8格式的,本来想用python,后来听说PowerShell很是强大,就试着用了一下,果然好用啊! $list = Get-ChildItem .\ - ...

  3. C++与lua交互

    项目开发的脚本层用的是Lua,引擎用的是C++.但是经理不给开放引擎层的代码.刚好最近项目空闲,安排了学习C++跟Lua的通信. 一.C++与Lua数据交互 数据交互主要是通过C API来实现 首先, ...

  4. 查询死锁和处理死锁(SqlServer)

    -------------------查询死锁,极其引起的原因-------------------------------use master go create procedure sp_who_ ...

  5. js让菜单栏一直悬浮在顶部,经典代码

    js让菜单栏一直悬浮在顶部,经典代码 很简单,你只需要把下面代码放到js中:$(function(){                //获取要定位元素距离浏览器顶部的距离        var na ...

  6. 博客换了,比较少用这个博客(http://loid.cf)

    新博客地址: http://loid.cf/

  7. 《Programming Massively Parallel Processors》Chapter5 习题解答

    自己做的部分习题解答,因为时间关系,有些马虎,也不全面,欢迎探讨或指出错误 5.1 Consider the matrixaddition in Exercise 3.1. Can one use s ...

  8. nexus4/5/6/7/9/10设备谷歌安卓5.1.1系统底包下载

    https://developers.google.com/android/nexus/images http://www.inexus.co/thread-18488-1-1.html

  9. 七、Solr服务部署和安全

    概念: 我们知道,Solr是以webapp的形式运行的,那么我们只需要把Solr.war文件部署到web容器中,便可以运行了,但是因为需要连接数据库做索引并且提供线上的服务调用query接口,那么So ...

  10. php增删改查,自己写的demo

    1.链接数据库通用方法:conn.php <?php //第一步:链接数据库 $conn=@mysql_connect("localhost:3306","root ...