Ruby http-access2
require 'pp'
require 'http-access2'
client = HTTPAccess2::Client.new()
# head = client.head('http://www.google.com')
# p head.header['Server'][0]
# content = client.get_content('http://www.google.com')
# puts content
# response = client.get('http://www.google.com/')
# pp response.header.get
# puts response.header.request_uri
# puts response.header.response_status_code
# pp response.header
# puts response.dump
# puts response.contenttype
# puts response.version
# puts response.status
# puts response.reason
# puts response.body.content
# puts response.content
# pp response.methods.sort
# puts response.content
=begin
== WebAgent::CookieManager Class
Load, save, parse and send cookies.
=== Usage
## initialize
## load from IE7 cookie file
cm = WebAgent::CookieManager.new("C:\Documents and Settings\user\Local Settings\Temporary Internet Files")
## load cookie data
cm.load_cookies()
## parse cookie from string (maybe "Set-Cookie:" header)
cm.parse(str)
## send cookie data to url
f.write(cm.find(url))
## save cookie to cookiefile
cm.save_cookies()
=== Class Methods
-- CookieManager::new(file=nil)
create new CookieManager. If a file is provided,
use it as cookies' file.
=== Methods
-- CookieManager#save_cookies(force = nil)
save cookies' data into file. if argument is true,
save data although data is not modified.
-- CookieManager#parse(str, url)
parse string and store cookie (to parse HTTP response header).
-- CookieManager#find(url)
get cookies and make into string (to send as HTTP request header).
-- CookieManager#add(cookie)
add new cookie.
-- CookieManager#load_cookies()
load cookies' data from file.
== WebAgent::CookieUtils Module
-- CookieUtils::head_match?(str1, str2)
-- CookieUtils::tail_match?(str1, str2)
-- CookieUtils::domain_match(host, domain)
-- CookieUtils::total_dot_num(str)
== WebAgent::Cookie Class
=== Class Methods
-- Cookie::new()
create new cookie.
=== Methods
-- Cookie#match?(url)
match cookie by url. if match, return true. otherwise,
return false.
-- Cookie#name
-- Cookie#name=(name)
-- Cookie#value
-- Cookie#value=(value)
-- Cookie#domain
-- Cookie#domain=(domain)
-- Cookie#path
-- Cookie#path=(path)
-- Cookie#expires
-- Cookie#expires=(expires)
-- Cookie#url
-- Cookie#url=(url)
accessor methods for cookie's items.
-- Cookie#discard?
-- Cookie#discard=(discard)
-- Cookie#use?
-- Cookie#use=(use)
-- Cookie#secure?
-- Cookie#secure=(secure)
-- Cookie#domain_orig?
-- Cookie#domain_orig=(domain_orig)
-- Cookie#path_orig?
-- Cookie#path_orig=(path_orig)
-- Cookie#override?
-- Cookie#override=(override)
-- Cookie#flag
-- Cookie#set_flag(flag_num)
accessor methods for flags.
=end
No comments :
Post a Comment