2013-04-06 4 views
0

해시에있는 "content"를 표시해야합니다. $ c-> header ("content")로 테스트하지만 아무것도 표시하지 않지만 콘텐츠 해시 값에이 경우 .HTTP :: Proxy in 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-> 콘텐츠의 내용을 변경하는 방법을 묻고 싶습니다. 이 내가 필요로하는 마지막 것입니다. – 14K

+0

'$ c-> 콘텐츠 ($ newcontent)'. – jordanm