[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Strange NoMethodError

Holger Biebinger

8/7/2006 2:31:00 PM

Hi,
In the following test script (similar to pickaxe p. 700 ):

require 'net/http'
require 'uri'

def fetch (uri_str, limit=10)
fail 'http redirect limit exceeded' if limit.zero?
response = Net::HTTP.get_response(URI.parse(uri_str))
case response
when Net::HTTPSuccess
response
when Net::HTTPRedirection
fetch(response['location'], limit-1)
else
response.error!
end
end


fetch('heise.de');


with
ruby test.rb
I get the result:

Exception `NoMethodError' at /usr/local/lib/ruby/1.8/net/http.rb:380
- undefined method `request_uri' for #<URI::Generic:0x188f84
URL:heise.de>
/usr/local/lib/ruby/1.8/net/http.rb:380:in `get_response': undefined
method `request_uri' for #<URI::Generic:0x188f84 URL:heise.de>
(NoMethodError)
from /usr/local/lib/ruby/1.8/net/http.rb:545:in `start'
from /usr/local/lib/ruby/1.8/net/http.rb:379:in `get_response'
from test.rb:6:in `fetch'
from test.rb:18


I had a look at /usr/local/lib/ruby/1.8/uri/http.rb
The function was defined there:
#
# == Description
#
# Returns: path + '?' + query
#
def request_uri
r = path_query
if r[0] != ?/
r = '/' + r
end

r
end

It should be a function of the standard libray. I am quite new to
ruby. How can I debug this problem? Or any hints what I can do?

Thanks in advance for your help,


Holger






3 Answers

Ara.T.Howard

8/7/2006 3:02:00 PM

0

Holger Biebinger

8/7/2006 6:51:00 PM

0

On Aug 7, 2006, at 5:02 PM, ara.t.howard@noaa.gov wrote:

> On Mon, 7 Aug 2006, Holger Biebinger wrote:
>
>> Hi,
>> In the following test script (similar to pickaxe p. 700 ):
>>
>> require 'net/http'
>> require 'uri'
>>
>> def fetch (uri_str, limit=10)
>> fail 'http redirect limit exceeded' if limit.zero?
>> response = Net::HTTP.get_response(URI.parse(uri_str))
>> case response
>> when Net::HTTPSuccess
>> response
>> when Net::HTTPRedirection
>> fetch(response['location'], limit-1)
>> else
>> response.error!
>> end
>> end
>>
>>
>> fetch('heise.de');
> ^^^^^^^^
> ^^^^^^^^
>
> this is not a uri.
>
> try
>
> harp:~ > ruby -r uri -e' p URI.parse("heise.de").host '
> nil
>
> harp:~ > ruby -r uri -e' p URI.parse("http://heis...).host '
> "heise.de"
>
> regards.
>
> -a

Oh my god ... thank you vey much. You are right. I was a it confused
because of the NoMethodError and I thought I had installed something
wrongly. Thanks for your hint :)

best regards,
Holger

Brad Guth

1/19/2009 12:47:00 PM

0

On Jan 18, 11:17 pm, "Seon Ferguson" <seo...@gmail.com> wrote:
> "BDK" <TopSh...@sanity.com> wrote in message
>
> > What what what? Guthball made sense to you?
>
> > Well Seon, it looks bad for you..
>
> > Lollipop.
>
> > --
>
> Most of what he says, yes.
> And Bush is a puppet. The question is will Obama be a puppet as well?

Wow, our resident Zionist/Nazi BDK certainly likes including loads of
impossible to follow context, by having to include/quote everything
under the sun. Apparently it's a MI5/CIA policy thing.

It's almost as though they is keeping records for some kind of
kangaroo court thing.

If BHO doesn't become a Zionist/Nazi puppet, he may not live long
enough to accomplish squat. Perhaps keeping a few live web cams on
his every move will at least make it easier to track down those
responsible.

~ BG