Ilya Grigorik wrote:> Chances are, you''re simply not calling net/http methods correctly,
there
> is no reason at all why net/http wouldn''t work with XML. (In fact,
I
> have it running in one of my applications.) Check your code against
> some samples in the RDoc. Why don''t you like open-uri?
>
> Ilya - http://www.igvita.com/blog
You know test open-uri against net/http to open one html file and
display it back. I test and realize that open-uri seems to be slower
than net/http. open-uri use 4.621 seconds and net/http use less than a
second.
The following I use two different library ''net/http'' and
''open-uri''. But
it returns different result. Why?
require ''net/http''
url =
URI.parse(''http://news.google.com/news?ned=us&topic=h&output=rss'')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
puts res.body
require ''open-uri''
path =
"http://news.google.com/news?ned=us&topic=h&output=rss"
content = ""
open(path) do |http|
content = http.read
end
puts content
The last thing I want to say is great blog, but I want to ask you more
"Does it still work on url like
''http://news.google.com/news?ned=us&topic=h&output=rss''?"
This is not a
file how can it know it has modified or not?
Thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---