文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>http 返回状态 模拟

http 返回状态 模拟

时间:2010-08-17  来源:liukaiyi


测试使用 : # status http 状态  # sleep 等待时间  秒  http://192.168.102.62:18080/test?status=200&sleep=0.2


{
   package MyWebServer;

   use HTTP::Server::Simple::CGI;
   use base qw(HTTP::Server::Simple::CGI);
   
  my %dispatch = (
    '/test' => \&resp_test,
    # ...

  );
 
 sub handle_request {
  my $self = shift;
  my $cgi = shift;
  my $status = $cgi->param('status');
  my $sleep = $cgi->param('sleep');
 
  my $path = $cgi->path_info();
  my $handler = $dispatch{$path};

  sleep( $sleep );
  if (ref($handler) eq "CODE") {
    print "HTTP/1.0 $status \r\n";
    print "Content-Type:text/xml; charset=utf8;\r\n\n";
    if( $status eq "200" ){
      print "<xml> <xml> 想想怎么错,也要错的有道理!!" ;
    }
  }
 }
 
 sub resp_test {

 }
   
}

my $pid = MyWebServer->new(18080)->background();
print "Use 'kill $pid' to stop server.\n";


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载