hi all,
in the course of my hacking i wanted to marshal mechanized objects
(whether the agent, page, or other). this may be a rather particular
use-case, but i figured i would report. marshalling does not work on
certain objects, in particular IO objects, and since mechanized uses
Net::HTTP it makes use of IO objects. so it turns out that it you
just do
a = WWW::Mechanize.new
page = a.get "http://nytimes.com"
Marhshal.dump(a)
you get a problem. in particular, "TypeError: can''t dump
TCPSocket".
basically, don''t try to marshal a socket.
however, if we make sure to finish the http connection after each use,
then the agent can be marshalled safely. i accomplished this by
inserting:
http_obj.finish
immediately prior to this line:
return page if res_klass <= Net::HTTPSuccess
in mechanize.rb, which is approximately line 587 in v 0.7.0
this is a crude hack that doesn''t, i think, respect keep-alive
connections, but it does at least work for the purpose of ensuring the
agent can be marshalled. i invite thoughts on more elegant solutions!
nick