<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div>Oi Renato e Tiago,</div><div><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">usando as instruções do pacote no cpan, eu obtive isto:<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br>use Net::FTP;<br>my $host = "ftp://hgdownload.cse.ucsc.edu/goldenPath/ce4/database/"; <br>my $ftp = Net::FTP->new($host, Firewall => 'http://10.46.10.19:3129')<br>    or die "Cannot connect to some.host.name: $@";<br>$ftp->size("all_est.txt.gz")<br>    or die "get failed ",
 $ftp->message;<br>$ftp->quit;<br>exit;<br><br>-------------------------------<br></div><div><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">- Primeira tentativa:</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span>$ time perl teste_proxy.pl<br>Cannot connect to some.host.name: Net::FTP: Bad hostname 'http://10.46.10.19:3129' at teste_proxy.pl line 18.<br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br><span></span></div><div
 style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">- Segunda tentativa, tirando o http:// do proxy:<br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span>$ perl teste_proxy.pl<br>Cannot connect to some.host.name:  at teste_proxy.pl line 18.<br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent;
 font-style: normal;"><span>- em alguma tentativa, também obtive isto:<br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span>$ perl teste_proxy.pl<br>Cannot connect to some.host.name: Net::FTP: Bad hostname 'ftp://hgdownload.cse.ucsc.edu/goldenPath/ce4/database/' at teste_proxy.pl line 18.<br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br>-------------------------------<br></div><div><br></div><div>Alguma ideia, sobre o que estou fazendo errado?<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif;
 background-color: transparent; font-style: normal;">[]'s</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">Nicole<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div>  <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">De:</span></b> Renato Santos <renato.cron@gmail.com><br> <b><span style="font-weight: bold;">Para:</span></b> Nicole Scherer <bionica2007-perl@yahoo.com> <br><b><span style="font-weight: bold;">Cc:</span></b> Perl Mongers Rio de Janeiro <rio-pm@pm.org> <br> <b><span style="font-weight:
 bold;">Enviadas:</span></b> Sexta-feira, 8 de Março de 2013 17:13<br> <b><span style="font-weight: bold;">Assunto:</span></b> Re: [Rio-pm] obtendo dados do HTTP header atraves de proxy<br> </font> </div> <br><div id="yiv31119764">Então você precisa verificar o seu proxy.<div><br></div><div>Mas como o Tiago disse, </div><div><br></div><div>porque vocẽ não conecta usando Net::FTP ? Ele tem modo anomimo.</div><div><br></div><div><br><br><div class="yiv31119764gmail_quote">

2013/3/8 Nicole Scherer <span dir="ltr"><<a rel="nofollow" ymailto="mailto:bionica2007-perl@yahoo.com" target="_blank" href="mailto:bionica2007-perl@yahoo.com">bionica2007-perl@yahoo.com</a>></span><br><blockquote class="yiv31119764gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div style="font-size:12pt;font-family:times new roman, new york, times, serif;">Sim, Renato,<br><br>usando o  LWP::Simple::get($downloadfile) eu consigo baixar o arquivo inclusive através do proxy.<br>Só o conteúdo do <span> LWP::Simple::head($downloadfile) é que não é o mesmo com ou sem proxy.<br>

Não sei se é porque ele usa o head() do</span> LWP::UserAgent, quando acionado o $ua para o proxy.<br><br>[]'s<span class="yiv31119764HOEnZb"><font color="#888888"><br>Nicole<br></font></span><div class="yiv31119764hm yiv31119764HOEnZb"><br><div><br>

</div>  </div><div style="font-family:times new roman, new york, times, serif;font-size:12pt;"><div class="yiv31119764hm yiv31119764HOEnZb"> </div><div style="font-family:times new roman, new york, times, serif;font-size:12pt;"><div class="yiv31119764hm yiv31119764HOEnZb">

 <div dir="ltr"> <font face="Arial"> <hr size="1">  <b><span style="font-weight:bold;">De:</span></b> Renato Santos <<a rel="nofollow" ymailto="mailto:renato.cron@gmail.com" target="_blank" href="mailto:renato.cron@gmail.com">renato.cron@gmail.com</a>><br> <b><span style="font-weight:bold;">Para:</span></b> Nicole Scherer <<a rel="nofollow" ymailto="mailto:bionica2007-perl@yahoo.com" target="_blank" href="mailto:bionica2007-perl@yahoo.com">bionica2007-perl@yahoo.com</a>>; Perl Mongers Rio de Janeiro
 <<a rel="nofollow" ymailto="mailto:rio-pm@pm.org" target="_blank" href="mailto:rio-pm@pm.org">rio-pm@pm.org</a>> <br> <b><span style="font-weight:bold;">Enviadas:</span></b> Sexta-feira, 8 de Março de 2013 17:01<br> <b><span style="font-weight:bold;">Assunto:</span></b> Re: [Rio-pm] obtendo dados do HTTP header atraves de proxy<br>

 </font> </div></div><div><div class="yiv31119764h5"> <br><div>Existe a possibilidade do seu proxy não estar repassando essas informações ou estar negando o acesso.<div><br></div><div>Você já tentou baixar o arquivo com o proxy ?<br>

<br><div>2013/3/8 Nicole Scherer <span dir="ltr"><<a rel="nofollow" ymailto="mailto:bionica2007-perl@yahoo.com" target="_blank" href="mailto:bionica2007-perl@yahoo.com">bionica2007-perl@yahoo.com</a>></span><br>

<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div style="font-size:12pt;font-family:times new roman, new york, times, serif;"><span>Oi Mongers,<br><br>venho humildemente consultar o vasto conhecimento de vocês em prol da pesquisa científica.<br>



<br>Preciso consultar o tamanho de um arquivo em um servidor ftp, antes de decidir se o arquivo deverá ou não ser baixado.<br>Eu estava usando o LWP::Simple::head($url) para isto, e estava funcionando bem, até eu ter que usá-lo através de um proxy.<br>



O que acontece é o seguinte, usando sem proxy, eu consigo acessar as informações sobre tamanho, formato, codificação, etc,<br><br><br>my $downloadfile = "<a rel="nofollow" target="_blank" href="ftp://hgdownload.cse.ucsc.edu/goldenPath/ce4/database/all_est.txt.gz">ftp://hgdownload.cse.ucsc.edu/goldenPath/ce4/database/all_est.txt.gz</a>";<br>



</span><span>my ($content_type, $document_length, $modified_time, $expires, $server) = LWP::Simple::head($downloadfile);<br><br>--- ou<br><br></span><span>if (my $res =
 LWP::Simple::head($downloadfile)) {<br>    print "$downloadfile ok\n"; ### debug<br>    p($res->{_headers});<br>} else {<br>    print "$downloadfile not available\n"; ### debug<br>}<br><br><br>--- e quando uso <br>



<br>use LWP::Simple qw($ua head);<br>$ua->proxy([qw(http ftp wais)], 'http://10.46.10.19:3129');<br><br></span><div>para definir o proxy, ele não retorna estas informações.</div><div><br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">Se eu mandar imprimir $res->{_headers}, tenho isso:</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">--- rodando sem proxy</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">HTTP::Headers  {<br>    public methods (38) : as_string, authorization, authorization_basic, clear, client_date, content_encoding, content_is_html, content_is_text, content_is_xhtml, content_is_xml, content_language, content_length, content_type, content_type_charset, date, expires, from, header, header_field_names, if_modified_since, if_unmodified_since, init_header, last_modified, new,
 proxy_authenticate, proxy_authorization, proxy_authorization_basic, push_header, referer, referrer, remove_content_headers, remove_header, scan, server, title, user_agent, warning, www_authenticate<br>    private methods (5) : _basic_auth, _date_header, _header, _process_newline, _sorted_field_names<br>



    internals: {<br>        client-date         =>  "Fri, 08 Mar 2013 19:33:58 GMT",<br>        client-request-num  =>  1,<br>        content-encoding    =>  "gzip",<br>        content-length      =>  14169205,<br>



        content-type        => 
 "text/plain",<br>        last-modified       =>  "Mon, 14 Mar 2011 16:52:05 GMT",<br>        server              =>  "FTP Server"<br>    }<br>}<br><br></div><br><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">--- com proxy</div>HTTP::Headers  {<br>    public methods (38) : as_string, authorization, authorization_basic, clear, client_date, content_encoding, content_is_html, content_is_text, content_is_xhtml, content_is_xml, content_language, content_length, content_type,
 content_type_charset, date, expires, from, header, header_field_names, if_modified_since, if_unmodified_since, init_header, last_modified, new, proxy_authenticate, proxy_authorization, proxy_authorization_basic, push_header, referer, referrer, remove_content_headers, remove_header, scan, server, title, user_agent, warning, www_authenticate<br>



    private methods (5) : _basic_auth, _date_header, _header, _process_newline, _sorted_field_names<br>    internals: {<br>        client-date          =>  "Fri, 08 Mar 2013 19:36:13 GMT",<br>        client-peer          =>  "<a rel="nofollow" target="_blank"  href="http://10.46.10.19:3129/">10.46.10.19:3129</a>",<br>



        client-response-num  =>  1,<br>       
 connection           =>  "close",<br>        date                 =>  "Fri, 08 Mar 2013 19:35:52 GMT"<br>    }<br>}<br><br><br><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">Ele simplesmente não cria/recebe content-encoding, content-length, content-type,  last-modified e  server. </div>



<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">Só o que eu preciso mesmo é o
 content-length.</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;"><br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



By the way, o LWP::UserAgent  head() não me informa o tamanho do arquivo. Pelo menos não nos meus testes.</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">Vocês conhecem alguma outra maneira de obter a informação de tamanho do arquivo sem ter que baixá-lo?</div>



<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">Acessando o directory listing também não dá, porque através do proxy, o formato que ele retorna varia em cada sistema (pelo menos foi o que eu observei. me corrijam se eu estiver errada).<br>



</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;"><br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">Obrigada!</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">Abraços,</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



Nicole<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;"><br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;">



<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman, new york, times, serif;"><br></div></div></div><br>_______________________________________________<br>
Rio-pm mailing list<br>
<a rel="nofollow" ymailto="mailto:Rio-pm@pm.org" target="_blank" href="mailto:Rio-pm@pm.org">Rio-pm@pm.org</a><br>
<a rel="nofollow" target="_blank" href="http://mail.pm.org/mailman/listinfo/rio-pm">http://mail.pm.org/mailman/listinfo/rio-pm</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><span style="color:rgb(51,51,51);font-size:x-small;">Saravá,</span></div>



<div><span style="color:rgb(51,51,51);font-size:x-small;">Renato CRON</span></div><div><div style="text-align:right;"><font color="#333333" size="1"><a rel="nofollow" target="_blank" href="http://www.renatocron.com/blog/">http://www.renatocron.com/blog/</a></font></div>



</div><div style="text-align:right;"><font color="#333333" size="1"><a rel="nofollow" target="_blank" href="http://twitter.com/#!/renato_cron">@renato_cron</a></font></div>
</div>
</div><br><br> </div></div></div> </div>  </div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><span style="color:rgb(51,51,51);font-size:x-small;">Saravá,</span></div><div><span style="color:rgb(51,51,51);font-size:x-small;">Renato CRON</span></div>

<div><div style="text-align:right;"><font color="#333333" size="1"><a rel="nofollow" target="_blank" href="http://www.renatocron.com/blog/">http://www.renatocron.com/blog/</a></font></div></div><div style="text-align:right;"><font color="#333333" size="1"><a rel="nofollow" target="_blank" href="http://twitter.com/#!/renato_cron">@renato_cron</a></font></div>


</div>
</div><br><br> </div> </div>  </div></body></html>