mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
No description
Change the signature of HTTP::Cookie.parse() so that it only optionally takes an origin URI. When one is given, the method checks if each piece of cookie in the header value is valid and acceptable from the origin to ignore unacceptable cookies. |
||
|---|---|---|
| lib | ||
| test | ||
| .gitignore | ||
| Gemfile | ||
| http-cookie.gemspec | ||
| LICENSE.txt | ||
| Rakefile | ||
| README.md | ||
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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request