响应头location 页面跳转
登陆;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 页面跳转的更多相关文章
- regexp模式匹配+location页面跳转+cookie/localstorage本地存储
学习js的过程中,根据知识点编写一些code进行测试,以便检验. 这段程序使用了以下知识点: 1.regexp,对数据进行模式匹配 2.使用location对象进行页面跳转. 3.cookie/loc ...
- nginx替换响应头(重点:如何在替换时加上if判断)
在实现微信小程序内嵌非业务域名时,通过nginx做镜像网站绕过小程序业务域名检测,但有一些表单页面提交后会返回一个302状态,由响应头Location的值决定提交成功后的跳转地址.那么问题来了,这个地 ...
- HTTP请求头和响应头
这篇文章简单总结一下HTTP请求头和响应头,并举一些web开发中响应头的用例. 1. HTTP请求头 accept:浏览器通过这个头告诉服务器,它所支持的数据类型.如:text/html, ima ...
- javaweb(四)——Http协议(请求头,响应头详解)
一.什么是HTTP协议 HTTP是hypertext transfer protocol(超文本传输协议)的简写,它是TCP/IP协议的一个应用层协议,用于定义WEB浏览器与WEB服务器之间交换数据的 ...
- Http协议请求头、响应头、响应码
Http部分请求头 Accept 客户机通过这个头,告诉服务器,它支持哪些数据类型 Accept-Charset 客户机通过这个头,告诉服务器,它支持的编码 Accept-Encoding 客户机通过 ...
- JavaWeb学习记录(一)——response响应头之缓存设置与下载功能的实现
一.HTTP中常用响应头 Location: http://www.it315.org/index.jsp Server:apache tomcat Content-Encoding: gzip Co ...
- 通过refresh响应头,定时刷新或隔n秒跳转页面
package day08; import java.io.IOException; import javax.servlet.ServletException; import javax.servl ...
- http 响应头之location
<pre name="code" class="html">jrhmpt01:/root# cat login_yylc.pl use LWP::U ...
- window.location.hash 页面跳转,精确定位,实例展示:
window.location.hash 页面跳转,精确定位,实例展示: (1).index.phtml,页面用于传参 <script id="bb_list_template&quo ...
随机推荐
- DLL模块例1:使用.def模块导出函数,规范修饰名称,显示连接调用dll中函数
以下内容,我看了多篇文章,整合在一起,写的一个例子,关于dll工程的创建,请参考博客里另一篇文章:http://www.cnblogs.com/pingge/articles/3153571.html ...
- hadoop2.2.0的ha分布式集群搭建
hadoop2.2.0 ha集群搭建 使用的文件如下: jdk-6u45-linux-x64.bin hadoop-2.2.0.x86_64.tar zookeeper-3.4.5. ...
- C程序设计语言--指针和引用的区别
在看了一篇文章以后,http://coolshell.cn/articles/7992.html,说的是C和C++之间的缺陷,当然这篇文章说的非常高深了.所以就找了一些资料,分析了这两者的区别 在&l ...
- BLOG PLUGINS
文章分享按钮 (1)加网(JiaThis) (2)百度分享 文章关联推荐 每篇博文下面可以显示你博客中与该篇博文有些关联的几篇文章,也就是智能推荐,一方面可以增加你博文的曝光率和点击率,一方面也可以给 ...
- css的存在形式以及优先级
css的存在形式以及优先级 css不仅仅可以在每个head标签中定义,而且也可以写在一个文件中,每个页面即可进行引用,这样可以做到重复利用. css文件的写法如下: common.css .c1{ h ...
- 学习手机游戏开发的两个方向 Cocos2d-x 和 Unity 3D/2D,哪个前景更好?
如题! 首先说一说学习手机游戏(移动游戏)这件事. 眼下移动互联网行业的在以井喷状态发展.全球几十亿人都持有智能终端设备(ios android),造就了非常多移动互联网创业机会: 一.移动社交 微信 ...
- XCode 打包问题巧遇
XCode 打包问题巧遇 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句: ...
- iOS蓝牙4.0协议简单介绍
iOS开发蓝牙4.0的框架是CoreBluetooth,本文主要介绍CoreBluetooth的使用,关于本文中的代码片段大多来自github上的一个demo,地址是myz1104/Bluetooth ...
- MySQL 加密/压缩函数
这些问题可能导致数据值的改变.一般而言,上述问题可能在你使用非二进制串数据类型(如char,varchar,text等数据类型)的情况下发生. AES_ENCRYPT()和AES_DECRYPT() ...
- vi & vim 基本指令(持续更新ing)
Abstract:1) 文本编辑模式: --INSERT--2)一般模式: --i.o.a.R--3)命令行命令模式 ...