No description
Find a file
Akinori MUSHA 0cf86222f6 Booleanize the value if the key name is suffixed with a "?".
Neglect the "!" suffix that is not suitable for an attribute name
while at it.
2012-10-17 20:26:40 +09:00
lib Booleanize the value if the key name is suffixed with a "?". 2012-10-17 20:26:40 +09:00
test Booleanize the value if the key name is suffixed with a "?". 2012-10-17 20:26:40 +09:00
.gitignore Import cookie related stuff from Mechanize. 2012-10-14 18:52:52 +09:00
Gemfile Import cookie related stuff from Mechanize. 2012-10-14 18:52:52 +09:00
http-cookie.gemspec Add bundler >= 1.2.0 as development dependency. 2012-10-14 22:09:04 +09:00
LICENSE.txt Import cookie related stuff from Mechanize. 2012-10-14 18:52:52 +09:00
Rakefile Import cookie related stuff from Mechanize. 2012-10-14 18:52:52 +09:00
README.md Fix a bad example that blindly eats a cookie without checking the origin. 2012-10-14 22:19:59 +09:00

HTTP::Cookie

HTTP::Cookie is a ruby library to handle HTTP cookies in a way both compliant with RFCs and compatible with today's major browsers.

It was originally a part of the Mechanize library, separated as an independent library in the hope of serving as a common component that is reusable from any HTTP related piece of software.

Installation

Add this line to your application's Gemfile:

gem 'http-cookie'

And then execute:

$ bundle

Or install it yourself as:

$ gem install http-cookie

Usage

# Initialize a cookie jar
jar = HTTP::CookieJar.new

# Load from a file
jar.load(filename) if File.exist?(filename)

# Store received cookies
HTTP::Cookie.parse(uri, set_cookie_header_value) { |cookie|
  jar << cookie if cookie.acceptable_from_uri?(uri)
}

# Extract cookies to send
cookie_value_to_send = jar.cookies(uri).join(', ')

# Save to a file
jar.save_as(filename)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request