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!