HTTP :: Perl中的代理

问题描述:

我需要显示哈希中的“内容”,我使用:$ c-> header(“content”)测试,但是不显示任何内容,但是在内容哈希值中。HTTP :: Perl中的代理

因为我可以显示_content?

哈希

<pre> 
$VAR1 = bless(
    { 
     '_protocol' => 'HTTP/1.1', 
     '_content' => '-----------------------------8283483225031 
Content-Disposition: form-data; name="archivo"; filename="GFWLIVESetupLog.txt" 
Content-Type: text/plain 

    l i v e R e d i s t : 0 
G F W L C l i e n t : 0 

-----------------------------8283483225031 
Content-Disposition: form-data; name="destino" 

C:/perl/test.txt 
-----------------------------8283483225031-- 
', 
     '_uri' => bless(
      do { 
       \(
        my $o = 
         'http://localhost/shell.php?uploa 
d=' 
       ); 
      }, 
      'URI::http' 
     ), 
     '_headers' => bless(
      { 
       'user-agent' => 'Mozilla/5.0 (Windows NT 
5.1; rv:19.0) Gecko/20100101 Firefox/19.0', 
       'accept' => 'text/html,application/xhtml 
+xml,application/xml;q=0.9,*/*;q=0.8', 
       'accept-language' => 'es-ar,es;q=0.8,en- 
us;q=0.5,en;q=0.3', 
       'cookie' => 'PHPSESSID=a8bkktvsripf6agpi 
fnma61qq4', 
       'content-length' => '378', 
       'host'   => 'localhost', 
       'via'   => '1.1 doddy-701c8cb49 (HTTP::Pro 
xy/0.20)', 
       'content-type' => 'multipart/form-data; 
boundary=---------------------------8283483225031', 
       'x-forwarded-for' => '127.0.0.1', 
       'referer'   => 'http://localhost/shell.php 
?upload=' 
      }, 
      'HTTP::Headers' 
     ), 
     '_method' => 'POST' 
    }, 
    'HTTP::Request' 
); 

</pre> 

来源:

use HTTP::Proxy; 
use HTTP::Proxy::BodyFilter::simple; 
use HTTP::Proxy::BodyFilter::complete; 
use Data::Dumper; 

my $server = HTTP::Proxy->new(port=>8080); 
$server->host(); 

$server->push_filter(mime=>undef,response => HTTP::Proxy::BodyFilter::complete->new()); 

$server->push_filter(
mime=>undef, 
request=>HTTP::Proxy::BodyFilter::simple->new(\&enable), 
response => HTTP::Proxy::BodyFilter::simple->new(\&enable2)); 

$server->start(); 

sub enable { 

    my($a,$b,$c,$d,$e) = @_; 

print $c->header("content"); 

    #print Dumper $c; 

} 

sub enable2 { 
my ($j,$k,$l,$m,$n) = @_; 
    print $$k; 
} 

PD:原谅我的英语不好

的内容是不是在头部。在您的翻斗车输出中,标题是由_headers键表示的HTTP::Headers对象。你想调用content方法。

$c->content; 

的可用方法的完整列表,请参阅HTTP::Request documentation

+0

伟大,完美的发球,我还有最后一个问题,我想问问你是如何改变的$ C-内容>通过简单的“Hello World” 内容是我需要 – 14K 2013-04-06 17:44:00

+0

的最后一件事'$ C->内容($ newcontent)'。 – jordanm 2013-04-06 17:51:35