|
Versions Of This Snippet::
Download a raw-text version of this code by clicking on "Download Version"
Latest Snippet Version: :1.0.a
req.header.keys { |key| header[key] = req.header[key][0] }
didn't work for me, to make it work I had to change the line to:
req.header.keys.each { |key| header[key] = req.header[key][0] }
--------
I also found that to fill the cookies in the WEBRick::HTTPResponse, in the
"Convert Net::HTTP::HTTPResponse to WEBrick::HTTPResponse" section, you need to do something like:
set_cookie(response, res)
def set_cookie(src, dst)
if str = src['set-cookie']
cookies = []
str.split(/,\s*/).each{|token|
if /^[^=]+;/o =~ token
cookies[-1] << ", " << token
elsif /=/o =~ token
cookies << token
else
cookies[-1] << ", " << token
end
}
dst.cookies.replace(cookies)
end
end
--------
Just my 2 cents, thanks for sharing that snippet, it inspired me.
Keep up the good work!
Submit a new versionYou can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others..
|
||||||||||||||||||||||||||||||||||||
