This is the code I am using to get the xml data from Apple's UK Top 10 rss feed:
xml = Net::HTTP.get_response(URI.parse('http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml')).body
Sinatra returns Errno::ECONNRESET at / - Connection reset by peer
.
The RSS url I used for this was generated from the Apple RSS generator here. The error occurs with other countries' rss feeds but does NOT occur with the default feed (US) found here. The backtrace is below:
/usr/lib/ruby/1.9.1/net/protocol.rb in read_nonblock
@rbuf << @io.read_nonblock(BUFSIZE)
/usr/lib/ruby/1.9.1/net/protocol.rb in rbuf_fill
@rbuf << @io.read_nonblock(BUFSIZE)
/usr/lib/ruby/1.9.1/net/protocol.rb in readuntil
rbuf_fill
/usr/lib/ruby/1.9.1/net/protocol.rb in readline
readuntil("\n").chop
/usr/lib/ruby/1.9.1/net/http.rb in read_status_line
str = sock.readline
/usr/lib/ruby/1.9.1/net/http.rb in read_new
httpv, code, msg = read_status_line(sock)
/usr/lib/ruby/1.9.1/net/http.rb in block in transport_request
res = HTTPResponse.read_new(@socket)
/usr/lib/ruby/1.9.1/net/http.rb in catch
res = catch(:response) {
/usr/lib/ruby/1.9.1/net/http.rb in transport_request
res = catch(:response) {
/usr/lib/ruby/1.9.1/net/http.rb in request
res = transport_request(req, &block)
/usr/lib/ruby/1.9.1/net/http.rb in request_get
request(Get.new(path, initheader), &block)
/usr/lib/ruby/1.9.1/net/http.rb in block in get_response
return http.request_get(uri.request_uri, &block)
/usr/lib/ruby/1.9.1/net/http.rb in start
return yield(self)
/usr/lib/ruby/1.9.1/net/http.rb in get_response
new(uri.hostname, uri.port).start {|http|
/home/sinatra/little.rb in block in <top (required)>
xml = Net::HTTP.get_response(URI.parse('https://itunes.apple.com/gb/rss/topsongs/limit=5/xml')).body
/usr/lib/ruby/1.9.1/webrick/httpserver.rb in service
si.service(req, res)
/usr/lib/ruby/1.9.1/webrick/httpserver.rb in run
server.service(req, res)
/usr/lib/ruby/1.9.1/webrick/server.rb in block in start_thread
block ? block.call(sock) : run(sock)