Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created February 1, 2009 03:02
Show Gist options
  • Save brandon-beacher/55772 to your computer and use it in GitHub Desktop.
Save brandon-beacher/55772 to your computer and use it in GitHub Desktop.
class KookieStore < CGI::Session::CookieStore
private
def read_cookie
# use the real cookie if we can
cookie = super
unless cookie
# didn't find the real cookie, is this a multipart upload?
match_data = /^multipart\/form-data; boundary=(.+)/.match @session.cgi.env_table["CONTENT_TYPE"]
if match_data
# it is a multipart upload - use cookie value in form data (if present)
boundary = WEBrick::HTTPUtils::dequote match_data[1]
form_data = WEBrick::HTTPUtils.parse_form_data @session.cgi.stdinput, boundary
cookie = form_data[@cookie_options["name"]]
end
end
cookie
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment