<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><span class="tab">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 = "ftp://hgdownload.cse.ucsc.edu/goldenPath/ce4/database/all_est.txt.gz";<br></span><span class="tab">my ($content_type, $document_length, $modified_time, $expires, $server) = LWP::Simple::head($downloadfile);<br><br>--- ou<br><br></span><span class="tab">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="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;">Se eu mandar imprimir $res->{_headers}, tenho isso:</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;">--- rodando sem proxy</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;">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="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;">--- 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          =>  "10.46.10.19:3129",<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="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;">Ele simplesmente não cria/recebe content-encoding, content-length, content-type,  last-modified e  server. </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ó o que eu preciso mesmo é o
 content-length.</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;">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="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;">Vocês conhecem alguma outra maneira de obter a informação de tamanho do arquivo sem ter que baixá-lo?</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;">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="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;"><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;">Obrigada!</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;">Abraços,</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="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;"><br></div></div></body></html>