in reply to XML::FeedPP Crashing Despite Eval

$ HEAD http://www.alarabiya.net/rss/en_meast.xml 200 OK Cache-Control: max-age=300, must-revalidate Connection: close Date: Thu, 25 Jun 2009 08:32:04 GMT Via: 1.1 12.120.13.61:80 (cache/2.6.2.1.2.ATT) Accept-Ranges: bytes Age: 147 ETag: "361876a-2ada-f61b9ec0" Server: Apache Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 3778 Content-Type: text/xml Expires: Thu, 25 Jun 2009 08:37:04 GMT Last-Modified: Thu, 25 Jun 2009 08:25:07 GMT Client-Date: Thu, 25 Jun 2009 13:31:46 GMT Client-Peer: 12.120.13.36:80 Client-Response-Num: 1 X-Cache: HIT from 12.120.13.61

Looks like the data that you're getting back is gzipped. You'll need to unzip it before processing it.

--

See the Copyright notice on my home node.

Perl training courses

Replies are listed 'Best First'.
Re^2: XML::FeedPP Crashing Despite Eval
by cormanaz (Deacon) on Jun 25, 2009 at 11:34 UTC
    Thanks! But WTF? I've never heard of a feed being gzipped. Does anyone know if this is common? Also why didn't eval trap the error?

      Zipping responses from web servers is pretty common. Browsers handle zipped content seamlessly.

      --

      See the Copyright notice on my home node.

      Perl training courses

      eval traps die, doesn't stop warnings, exit ...

      You get back gzip compressed content because ...

      1. The server is able to compress the requested content on-the-fly (typically, because gzip_cnc or mod_gzip are installed), and
      2. your user-agent said that it could handle gzip-compressed content ("Accept-Encoding" header)

      or

      1. The server is able to compress the requested content on-the-fly, and
      2. the server does not care about the capabilities of the user-agent

      In the first case, make sure that the announced and the real capabilities of your user-agent match, i.e. don't send "Accept-Encoding: gzip" if you can't or don't want to handle gzip-compressed content.

      In the latter case, the server is misconfigured, either accidentally or intentionally. All currently and commonly used browsers can handle gzip compressed content, so not checking the capabilities at all save a few thousand CPU cycles and some lines of code. Of course, this is not what I would call a well-behaved server.

      See also http://schroepl.net/projekte/mod_gzip/encoding.htm

      Your eval "surprise" was already explained: eval traps die, nothing less, nothing more. It does not help you with code that exits or messes up perl's internal structures.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)