in reply to Re: Mechanize Returns Garbled Content
in thread Mechanize Returns Garbled Content

Both machines returned some header information. On the 'good' machine, it returned this.
Cache-Control: private, max-age=0 Connection: close Date: Tue, 28 Jun 2011 22:45:06 GMT Server: gws Content-Type: text/html; charset=ISO-8859-1 Expires: -1 Client-Date: Tue, 28 Jun 2011 22:43:19 GMT Client-Peer: xx.xx.xx.xx:80 Client-Response-Num: 1 Set-Cookie: PREF=ID=c390276a4d39152b:FF=0:TM=1309301106:LM=1309301106: +S=OOuAOCNBYRLJCHWp; expires=Thu, 27-Jun-2013 22:45:06 GMT; path=/; do +main=.google.com Set-Cookie: NID=48=H5aMKdl8PlT40vE7xU3rxWQ0Py7lY4AXt8L-BJ9q3ZIp4QN8riF +AnUTh_gYtX6s_dG-pf3FFPKLs1M80BC2z3SDbma5vGWFi_h0wgCmHSbQzCYFW0nD2KoyE +I4FxEukb; expires=Wed, 28-Dec-2011 22:45:06 GMT; path=/; domain=.goog +le.com; HttpOnly Title: Google X-Meta-Description: Search the world's information, including webpages +, images, videos and more. Google has many special features to help y +ou find exactly what you're looking for. X-Meta-Robots: noodp X-XSS-Protection: 1; mode=block
On the 'bad' machine, it returned this.
Cache-Control: private, max-age=0 Connection: close Date: Tue, 28 Jun 2011 22:45:19 GMT Server: gws Content-Encoding: gzip Content-Length: 6075 Content-Type: text/html; charset=UTF-8 Expires: -1 Client-Date: Tue, 28 Jun 2011 22:45:19 GMT Client-Peer: xx.xx.xx.xx:80 Client-Response-Num: 1 Set-Cookie: PREF=ID=ee94fe222925b98d:FF=0:TM=1309301119:LM=1309301119: +S=93SJpaSxcxzXIjMh; expires=Thu, 27-Jun-2013 22:45:19 GMT; path=/; do +main=.google.com Set-Cookie: NID=48=Zvuevcb_CgIY6rP-Gq65L1oR6r41cs3nYFNAFNoYfwOqFZxcBhr +bW_x4PTjTfgVmh7fovclmf2dWwJu6F-c6NGvMQhdoASsxN07mlNVP1Pi7XbeL6LeqkhJ9 +Jvy8wCj7; expires=Wed, 28-Dec-2011 22:45:19 GMT; path=/; domain=.goog +le.com; HttpOnly X-XSS-Protection: 1; mode=block
Both response are different and the 'bad' machine seems to think that the content is gzip?

Replies are listed 'Best First'.
Re^3: Mechanize Returns Garbled Content
by ikegami (Patriarch) on Jun 29, 2011 at 00:17 UTC

    Content-Encoding: gzip accounts for the garbling, but WWW::Mechanize uses ->decoded_content to handle that. Try upgrading

    • WWW::Mechanize
    • IO::Uncompress::Gunzip
    • HTTP::Message

      Try upgrading

      Doh, I can't believe I'd guess that some type of network thingamabob would be the culprit before this. I hope I remember that next time...

        Well, there are differences in the responses (the character set and the content encoding are different), and that could be caused by some type of network thingamabob.

        The catch is that I think the relevant difference should be handled by the module automatically.

Re^3: Mechanize Returns Garbled Content
by ww (Archbishop) on Jun 29, 2011 at 01:10 UTC

    "Line 5 from the good machine: Content-Type: text/html; charset=ISO-8859-1
    Line 7 from the "bad" machine: Content-Type: text/html; charset=UTF-8
    "

    Could the bolded difference make a difference?

      How would I tell the "bad" machine to use charset=ISO-88590-1? Do you think this would work?
      $m->add_header( charset => 'ISO-8859-1' );

        It's not the bad machine that uses iso-88590-1, it's Google.

        Don't know why Google doesn't use the same for both*, but that code won't help.

        Unless you can see mostly recognisable text including "<html>" in the output, this isn't related to your question.

        * — Presumably, you don't send the same request.