Perform markups.

This commit is contained in:
Akinori MUSHA 2013-03-15 10:12:08 +09:00
parent c0d5f3a121
commit f7bb9d6272

View file

@ -1,15 +1,16 @@
# HTTP::Cookie # HTTP::Cookie
HTTP::Cookie is a ruby library to handle HTTP cookies in a way both `HTTP::Cookie` is a ruby library to handle HTTP cookies in a way both
compliant with RFCs and compatible with today's major browsers. compliant with RFCs and compatible with today's major browsers.
It was originally a part of the Mechanize library, separated as an It was originally a part of the
independent library in the hope of serving as a common component that [Mechanize](https://github.com/sparklemotion/mechanize) library,
is reusable from any HTTP related piece of software. 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 ## Installation
Add this line to your application's Gemfile: Add this line to your application's `Gemfile`:
gem 'http-cookie' gem 'http-cookie'
@ -59,13 +60,14 @@ Or install it yourself as:
set_cookie_header_value = cookies.set_cookie_value(my_url) set_cookie_header_value = cookies.set_cookie_value(my_url)
## Incompatibilities with Mechanize::Cookie and CookieJar ## Incompatibilities with `Mechanize::Cookie`/`CookieJar`
There are several incompatibilities with Mechanize::Cookie and There are several incompatibilities between
CookieJar. Below is how to rewrite existing code written for `Mechanize::Cookie`/`CookieJar` and `HTTP::Cookie`/`CookieJar`. Below
Mechanize::Cookie with equivalent using HTTP::Cookie: is how to rewrite existing code written for `Mechanize::Cookie` with
equivalent using `HTTP::Cookie`:
- Mechanize::Cookie.parse - `Mechanize::Cookie.parse`
# before # before
cookie1 = Mechanize::Cookie.parse(uri, set_cookie1) cookie1 = Mechanize::Cookie.parse(uri, set_cookie1)
@ -75,7 +77,7 @@ Mechanize::Cookie with equivalent using HTTP::Cookie:
cookie1 = HTTP::Cookie.parse(set_cookie1, :origin => uri) cookie1 = HTTP::Cookie.parse(set_cookie1, :origin => uri)
cookie2 = HTTP::Cookie.parse(set_cookie2, :origin => uri, :logger => log) cookie2 = HTTP::Cookie.parse(set_cookie2, :origin => uri, :logger => log)
- Mechanize::Cookie#set_domain - `Mechanize::Cookie#set_domain`
# before # before
cookie.set_domain(domain) cookie.set_domain(domain)
@ -83,7 +85,7 @@ Mechanize::Cookie with equivalent using HTTP::Cookie:
# after # after
cookie.domain = domain cookie.domain = domain
- Mechanize::CookieJar#add, #add! - `Mechanize::CookieJar#add`, `#add!`
# before # before
jar.add!(cookie1) jar.add!(cookie1)
@ -93,7 +95,7 @@ Mechanize::Cookie with equivalent using HTTP::Cookie:
jar.add(cookie1) jar.add(cookie1)
cookie2.origin = uri; jar.add(cookie2) # or specify origin in parse() or new() cookie2.origin = uri; jar.add(cookie2) # or specify origin in parse() or new()
- Mechanize::CookieJar#clear! - `Mechanize::CookieJar#clear!`
# before # before
jar.clear! jar.clear!
@ -101,7 +103,7 @@ Mechanize::Cookie with equivalent using HTTP::Cookie:
# after # after
jar.clear jar.clear
- Mechanize::CookieJar#save_as - `Mechanize::CookieJar#save_as`
# before # before
jar.save_as(file) jar.save_as(file)
@ -109,15 +111,16 @@ Mechanize::Cookie with equivalent using HTTP::Cookie:
# after # after
jar.save(file) jar.save(file)
HTTP::Cookie and CookieJar raises runtime errors to help migration, so `HTTP::Cookie` and `CookieJar` raises runtime errors to help
try running your test code once to find out how to fix your code base. migration, so try running your test code once to find out how to fix
your code base.
The YAML serialization format has changed. Loading YAML files The YAML serialization format has changed. Loading YAML files
generated by Mechanize::CookieJar#save_as will not raise an exception, generated by `Mechanize::CookieJar#save_as` will not raise an
but the content is simply ignored. Note that there is (obviously) no exception, but the content is simply ignored. Note that there is
forward compatibillity in the YAML serialization. Trying to load a (obviously) no forward compatibillity in the YAML serialization.
YAML file saved by HTTP::CookieJar with Mechanize::CookieJar will fail Trying to load a YAML file saved by `HTTP::CookieJar` with
in ArgumentError. `Mechanize::CookieJar` will fail in `ArgumentError`.
On the other hand, there has been (and will ever be) no change in the On the other hand, there has been (and will ever be) no change in the
cookies.txt format. cookies.txt format.