[ahoward@localhost ~]$ cat a.rb
require "http-access2"
cm = WebAgent::CookieManager::new "cookies"
cm.load_cookies
cookie = cm.cookies.first
url = cookie.url
matches = cookie.domain_match url.host, cookie.domain
puts "domain_match('#{ url.host }', '#{ cookie.domain }') => #{ matches }"
module WebAgent::CookieUtils
def domain_match(host, domain)
case domain
when /\d+\.\d+\.\d+\.\d+/
return (host == domain)
when '.'
return true
when /^\./
#return tail_match?(domain, host)
return tail_match?(host, domain)
else
return (host == domain)
end
end
end
matches = cookie.domain_match url.host, cookie.domain
puts "domain_match('#{ url.host }', '#{ cookie.domain }') => #{ matches }"
[ahoward@localhost ~]$ cat cookies
http://rubyforge.org//account/login.php session_ser LjEwMy45Ni40Ni0q%2A-fa0537de8cc31 1131676286 .rubyforge.org / 13
[ahoward@localhost ~]$ ruby a.rb
domain_match('rubyforge.org', '.rubyforge.org') => false
domain_match('rubyforge.org', '.rubyforge.org') => true
without this fix cookies do not round trip as they are not found by
Cookie#find.
regards.
-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| anything that contradicts experience and logic should be abandoned.
| -- h.h. the 14th dalai lama
===============================================================================
Hi,
I would like to encourage you to drop the "2" from the package name. Is
there a "1" and is "1" in common use? Also I encourage you to move
Cookie out of WebAgent namespace since it is no longer part of the
TAKAHASHI `Maki' Masayoshi's WebAgent program.
Thanks for excellent lib!
T.
tran...@gmail.com wrote:
> I would like to encourage you to drop the "2" from the package name. Is
> there a "1" and is "1" in common use? Also I encourage you to move
There was "http-access" package by Maehashi-san. Unfortunately the
author terminated(?) it. Net::HTTP and http-access2 were children of
the package. As far as I know Net::HTTP was almost rewritten but
http-access2 still contains HTTP/1.1 parsing state machine of http-access.
Aside from this, I'll change package name and class name if I find a
good name. What do you think "SOAP::HTTPClient"? :-)
> Cookie out of WebAgent namespace since it is no longer part of the
> TAKAHASHI `Maki' Masayoshi's WebAgent program.
I just applied patches from users to WebAgent::Cookie. I almost did
nothing. But I agree with you its module name should be changed. If I
find a good name...
Regards,
// NaHi
I see. Thanks.
Well, I'm no expert on these matters, but...
> Aside from this, I'll change package name and class name if I find a
> good name. What do you think "SOAP::HTTPClient"? :-)
SOAP? More like REST::HTTPClient ?
But maybe just use HTTP namespace? HttpClient = HTTP::Client?
> > Cookie out of WebAgent namespace since it is no longer part of the
> > TAKAHASHI `Maki' Masayoshi's WebAgent program.
>
> I just applied patches from users to WebAgent::Cookie. I almost did
> nothing. But I agree with you its module name should be changed. If I
> find a good name...
I definitely think HTTP::Cookie in this case is appropraite.
regards,
T.
Huh. Like I said I'm no expert. I didn't realize you could use it like
that. I use it to build a sort-of web-api to Rubyforge. I thought REST
b/c of that --no SOAP envelopes involved..
> > But maybe just use HTTP namespace? HttpClient = HTTP::Client?
>
> Hmm. Too generic I think. Implementing HTTP protocol is preserved for
> Net::HTTP. Handling HTTP resources is for open-uri. I hope
> http-access2 used for creating HTTP client agent.
HTTP::API -> HTTPAPI -> HTPAPPY -> HitPappy ;)
T.