File: //proc/self/root/opt/alt/ruby32/share/gems/doc/http-cookie-1.1.0/ri/page-README_md.ri
U:RDoc::TopLevel[ i I"README.md:ETcRDoc::Parser::Markdowno:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;[I"`{rdoc-image:https://badge.fury.io/rb/http-cookie.svg}[https://badge.fury.io/rb/http-cookie];TS:RDoc::Markup::Heading:
leveli: textI"HTTP::Cookie;To; ;[I"�HTTP::Cookie is a ruby library to handle HTTP cookies in a way both
compliant with RFCs and compatible with today's major browsers.;To; ;[I"�It was originally a part of the
{Mechanize}[https://github.com/sparklemotion/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.;To; ;[I"9The following is an incomplete list of its features:;To:RDoc::Markup::List:
@type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"PIts behavior is highly compatible with that of today's major web
browsers.;Fo;;0;[o; ;[I"�It is based on and conforms to RFC 6265 (the latest standard for the
HTTP cookie mechanism) to a high extent, with real world conventions
deeply in mind.;Fo;;0;[o; ;[I"It takes eTLD (effective TLD, also known as "Public Suffix") into
account just as major browsers do, to reject cookies with an eTLD
domain like "org", "co.jp", or "appspot.com". This feature is
brought to you by the
{domain_name}[https://github.com/knu/ruby-domain_name] gem.;Fo;;0;[o; ;[I"iThe number of cookies and the size are properly capped so that a
cookie store does not get flooded.;Fo;;0;[o; ;[I"�It supports the legacy Netscape cookies.txt format for
serialization, maximizing the interoperability with other
implementations.;Fo;;0;[o; ;[I"�It supports the cookies.sqlite format adopted by Mozilla Firefox for
backend store database which can be shared among multiple program
instances.;Fo;;0;[o; ;[I"lIt is relatively easy to add a new serialization format or a backend
store because of its modular API.;FS;
;i;I"Installation;To; ;[I">Add this line to your application's <code>Gemfile</code>:;To:RDoc::Markup::Verbatim;[I"gem 'http-cookie'
;T:@format0o; ;[I"And then execute:;To;;[I"$ bundle
;T;0o; ;[I"Or install it yourself as:;To;;[I"$ gem install http-cookie
;T;0S;
;i;I"
Usage;To;;[EI"########################
;TI"# Client side example 1
;TI"########################
;TI"
;TI"# Initialize a cookie jar
;TI"jar = HTTP::CookieJar.new
;T@YI"# Load from a file
;TI"1jar.load(filename) if File.exist?(filename)
;T@YI"F# Store received cookies, where uri is the origin of this header
;TI")header["Set-Cookie"].each { |value|
;TI" jar.parse(value, uri)
;TI"}
;T@YI"# ...
;T@YI"E# Set the Cookie header value, where uri is the destination URI
;TI"Dheader["Cookie"] = HTTP::Cookie.cookie_value(jar.cookies(uri))
;T@YI"# Save to a file
;TI"jar.save(filename)
;T@Y@YI"########################
;TI"# Client side example 2
;TI"########################
;T@YI"J# Initialize a cookie jar using a Mozilla compatible SQLite3 backend
;TI"Ljar = HTTP::CookieJar.new(store: :mozilla, filename: 'cookies.sqlite')
;T@YI"9# There is no need for load & save in this backend.
;T@YI"F# Store received cookies, where uri is the origin of this header
;TI")header["Set-Cookie"].each { |value|
;TI" jar.parse(value, uri)
;TI"}
;T@YI"# ...
;T@YI"E# Set the Cookie header value, where uri is the destination URI
;TI"Dheader["Cookie"] = HTTP::Cookie.cookie_value(jar.cookies(uri))
;T@Y@YI"########################
;TI"# Server side example
;TI"########################
;T@YI" # Generate a domain cookie
;TI"Hcookie1 = HTTP::Cookie.new("uid", "u12345", domain: 'example.org',
;TI"C for_domain: true,
;TI"< path: '/',
;TI"C max_age: 7*86400)
;T@YI"0# Add it to the Set-Cookie response header
;TI"5header['Set-Cookie'] = cookie1.set_cookie_value
;T@YI"## Generate a host-only cookie
;TI"Acookie2 = HTTP::Cookie.new("aid", "a12345", origin: my_url,
;TI"< path: '/',
;TI"C max_age: 7*86400)
;T@YI"0# Add it to the Set-Cookie response header
;TI"5header['Set-Cookie'] = cookie2.set_cookie_value
;T;0S;
;i;I"7Incompatibilities with Mechanize::Cookie/CookieJar;To; ;[I"�There are several incompatibilities between
Mechanize::Cookie/CookieJar and HTTP::Cookie/CookieJar. Below
is how to rewrite existing code written for Mechanize::Cookie with
equivalent using HTTP::Cookie:;To;
;;;[
o;;0;[o; ;[I"Mechanize::Cookie.parse;Fo; ;[I"7The parameter order changed in HTTP::Cookie.parse.;Fo;;[I"# before
;FI":cookies1 = Mechanize::Cookie.parse(uri, set_cookie1)
;FI"?cookies2 = Mechanize::Cookie.parse(uri, set_cookie2, log)
;F@YI"
# after
;FI"<cookies1 = HTTP::Cookie.parse(set_cookie1, uri_or_url)
;FI"Icookies2 = HTTP::Cookie.parse(set_cookie2, uri_or_url, logger: log)
;FI"<# or you can directly store parsed cookies in your jar
;FI"(jar.parse(set_cookie1, uri_or_url)
;FI"5jar.parse(set_cookie1, uri_or_url, logger: log)
;F;0o;;0;[o; ;[I")Mechanize::Cookie#version, #version=;Fo; ;[I"�There is no longer a sense of version in the HTTP cookie
specification. The only version number ever defined was zero, and
there will be no other version defined since the version attribute
has been removed in RFC 6265.;Fo;;0;[o; ;[I")Mechanize::Cookie#comment, #comment=;Fo; ;[I"?Ditto. The comment attribute has been removed in RFC 6265.;Fo;;0;[o; ;[I"!Mechanize::Cookie#set_domain;Fo; ;[I"RThis method was unintentionally made public. Simply use
HTTP::Cookie#domain=.;Fo;;[
I"# before
;FI"cookie.set_domain(domain)
;F@YI"
# after
;FI"cookie.domain = domain
;F;0o;;0;[o; ;[I"$Mechanize::CookieJar#add, #add!;Fo; ;[I"$Always use HTTP::CookieJar#add.;Fo;;[I"# before
;FI"jar.add!(cookie1)
;FI"jar.add(uri, cookie2)
;F@YI"
# after
;FI"jar.add(cookie1)
;FI"Ucookie2.origin = uri; jar.add(cookie2) # or specify origin in parse() or new()
;F;0o;;0;[o; ;[I" Mechanize::CookieJar#clear!;Fo; ;[I"Use HTTP::Cookiejar#clear.;Fo;;[
I"# before
;FI"jar.clear!
;F@YI"
# after
;FI"jar.clear
;F;0o;;0;[o; ;[I"!Mechanize::CookieJar#save_as;Fo; ;[I"Use HTTP::CookieJar#save.;Fo;;[
I"# before
;FI"jar.save_as(file)
;F@YI"
# after
;FI"jar.save(file)
;F;0o;;0;[o; ;[I"Mechanize::CookieJar#jar;Fo; ;[I"There is no direct access to the internal hash in HTTP::CookieJar
since it has introduced an abstract store layer. If you want to
tweak the internals of the hash store, try creating a new store
class referring to the default store class
HTTP::CookieJar::HashStore.;Fo; ;[I"�If you desperately need it you can access it by
<code>jar.store.instance_variable_get(:@jar)</code>, but there is no
guarantee that it will remain available in the future.;Fo; ;[I"�HTTP::Cookie/CookieJar raises runtime errors to help migration, so
after replacing the class names, try running your test code once to
find out how to fix your code base.;TS;
;i;I"File formats;To; ;[I"The YAML serialization format has changed, and HTTP::CookieJar#load
cannot import what is written in a YAML file saved by
Mechanize::CookieJar#save_as. HTTP::CookieJar#load will not raise an
exception if an incompatible YAML file is given, but the content is
silently ignored.;To; ;[I"�Note that there is (obviously) no forward compatibillity with this.
Trying to load a YAML file saved by HTTP::CookieJar with
Mechanize::CookieJar will fail in runtime error.;To; ;[I"�On the other hand, there has been (and will ever be) no change in the
cookies.txt format, so use it instead if compatibility is significant.;TS;
;i;I"Contributing;To;
;:NUMBER;[
o;;0;[o; ;[I"Fork it;To;;0;[o; ;[I"MCreate your feature branch (<code>git checkout -b my-new-feature</code>);To;;0;[o; ;[I"ICommit your changes (<code>git commit -am 'Add some feature'</code>);To;;0;[o; ;[I"EPush to the branch (<code>git push origin my-new-feature</code>);To;;0;[o; ;[I"Create new Pull Request;T:
@file@:0@omit_headings_from_table_of_contents_below0