2013-04-06 51 views
0

我需要顯示哈希中的「內容」,我使用:$ 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:原諒我的英語不好

回答

1

的內容是不是在頭部。在您的翻斗車輸出中,標題是由_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