lwp

How can I accept gzip-compressed content using LWP::UserAgent?

筅森魡賤 提交于 2019-11-27 05:33:31
问题 I am fetching some pages over the Web using Perl's LWP::UserAgent and would like to be as polite as possible. By default, LWP::UserAgent does not seamlessly handle compressed content via gzip. Is there an easy way to make it do so, to save everyone some bandwidth? 回答1: LWP has this capability built in, thanks to HTTP::Message. But it's a bit hidden. First make sure you have Compress::Zlib installed so you can handle gzip . HTTP::Message::decodable() will output a list of allowed encodings

True timeout on LWP::UserAgent request method

六月ゝ 毕业季﹏ 提交于 2019-11-27 02:15:05
问题 I am trying to implement a request to an unreliable server. The request is a nice to have, but not 100% required for my perl script to successfully complete. The problem is that the server will occasionally deadlock (we're trying to figure out why) and the request will never succeed. Since the server thinks it is live, it keeps the socket connection open thus LWP::UserAgent's timeout value does us no good what-so-ever. What is the best way to enforce an absolute timeout on a request? FYI,

How can I get LWP to validate SSL server certificates?

放肆的年华 提交于 2019-11-26 22:35:14
问题 How can I get LWP to verify that the certificate of the server I'm connecting to is signed by a trusted authority and issued to the correct host? As far as I can tell, it doesn't even check that the certificate claims to be for the hostname I'm connecting to. That seems like a major security hole (especially with the recent DNS vulnerabilities). Update: It turns out what I really wanted was HTTPS_CA_DIR , because I don't have a ca-bundle.crt. But HTTPS_CA_DIR=/usr/share/ca-certificates/ did