# Net/http with rss

**URL:** <https://www.ruby-forum.com/t/net-http-with-rss/88791>\
**Category:** Rails\
**Created:** [March 14, 2007, 12:35pm UTC](https://www.ruby-forum.com/t/net-http-with-rss/88791 "2007-03-14T12:35:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [March 14, 2007, 12:35pm UTC](https://www.ruby-forum.com/t/net-http-with-rss/88791/1 "2007-03-14T12:35:25Z")

</div>

Hello

I have one problem. I cannot use the library net/http to download the  
rss file. Why when I use it with rss file, it display nothing, but with  
other files, it works normally. Does anyone know how to do this? I don’t  
want to use open-uri library to work with the rss.

---

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [March 19, 2007, 10:46am UTC](https://www.ruby-forum.com/t/net-http-with-rss/88791/2 "2007-03-19T10:46:34Z")

</div>

Ilya G. 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 - [Ilya Grigorik](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(‘[Top stories - Google News](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  
‘[Top stories - Google News](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

---

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [March 14, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/net-http-with-rss/88791/3 "2007-03-14T15:48:03Z")

</div>

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 - [Ilya Grigorik](http://www.igvita.com/blog)
