Geturl with net/http package

R

Rasmus Debitsch

Hello,

I want to retrieve an image from the world wind server using the Ruby http
package. But I can't get it work. In tcl/tk it works like this:

package require http
set url "http://data.worldwind.arc.nasa.gov/t?T=105&L=0&X=81&Y=48"
set token [::http:geturl $url]
upvar #0 $token state

and the jpeg image is in the state(body) variable. Using Ruby I expected
something like this:

require 'net/http'
server = 'http://data.worldwind.arc.nasa.gov'
request = '/t?T=105&L=0&X=81&Y=48'
http = Net::HTTP.new(server)
http.start
resp,data = http.get(request, nil)
http.finish

But http.start returns "SocketError: getaddrinfo: no address associated with
hostname." always. Is there a command like geturl in the net/http package?
 
B

Brock Weaver

You behind a proxy? There is another method in http which takes proxy
host / port as an argument.

Hello,
=20
I want to retrieve an image from the world wind server using the Ruby htt= p
package. But I can't get it work. In tcl/tk it works like this:
=20
package require http
set url "http://data.worldwind.arc.nasa.gov/t?T=3D105&L=3D0&X=3D81&Y=3D48= "
set token [::http:geturl $url]
upvar #0 $token state
=20
and the jpeg image is in the state(body) variable. Using Ruby I expected
something like this:
=20
require 'net/http'
server =3D 'http://data.worldwind.arc.nasa.gov'
request =3D '/t?T=3D105&L=3D0&X=3D81&Y=3D48'
http =3D Net::HTTP.new(server)
http.start
resp,data =3D http.get(request, nil)
http.finish
=20
But http.start returns "SocketError: getaddrinfo: no address associated w= ith
hostname." always. Is there a command like geturl in the net/http package= ?
--
Rasmus
=20
=20
=20
=20


--=20
Brock Weaver
http://www.circaware.com
 
M

Mohit Muthanna

Remove the 'http://' from the 'server' variable.

Hello,
=20
I want to retrieve an image from the world wind server using the Ruby htt= p
package. But I can't get it work. In tcl/tk it works like this:
=20
package require http
set url "http://data.worldwind.arc.nasa.gov/t?T=3D105&L=3D0&X=3D81&Y=3D48= "
set token [::http:geturl $url]
upvar #0 $token state
=20
and the jpeg image is in the state(body) variable. Using Ruby I expected
something like this:
=20
require 'net/http'
server =3D 'http://data.worldwind.arc.nasa.gov'
request =3D '/t?T=3D105&L=3D0&X=3D81&Y=3D48'
http =3D Net::HTTP.new(server)
http.start
resp,data =3D http.get(request, nil)
http.finish
=20
But http.start returns "SocketError: getaddrinfo: no address associated w= ith
hostname." always. Is there a command like geturl in the net/http package= ?
--
Rasmus
=20
=20
=20
=20


--=20
Mohit Muthanna [mohit (at) muthanna (uhuh) com]
"There are 10 types of people. Those who understand binary, and those
who don't."
 
D

Daniel Berger

Mohit said:
Remove the 'http://' from the 'server' variable.

It would take a minimal amount of code to make it work with or without
the "http://" prefix. Any chance this could be patched?

I also recommend accessors for @address and @port.

Regards,

Dan
 
B

Brock Weaver

I'd say the server method shouldn't accept url specs
(http://servername is not a server name, it is a url). There could be
a url or address method which accepts a url (i.e.
protocol://server:port/request), but the methods server, port, and
request should accept just that.

=20

=20
It would take a minimal amount of code to make it work with or without
the "http://" prefix. Any chance this could be patched?
=20
I also recommend accessors for @address and @port.
=20
Regards,
=20
Dan
=20
=20
=20


--=20
Brock Weaver
http://www.circaware.com
 
R

Rasmus Debitsch

Now it works. Sometimes it is so easy.
Thanks,
Rasmus

Remove the 'http://' from the 'server' variable.

Hello,

I want to retrieve an image from the world wind server using the Ruby http
package. But I can't get it work. In tcl/tk it works like this:

package require http
set url "http://data.worldwind.arc.nasa.gov/t?T=105&L=0&X=81&Y=48"
set token [::http:geturl $url]
upvar #0 $token state

and the jpeg image is in the state(body) variable. Using Ruby I expected
something like this:

require 'net/http'
server = 'http://data.worldwind.arc.nasa.gov'
request = '/t?T=105&L=0&X=81&Y=48'
http = Net::HTTP.new(server)
http.start
resp,data = http.get(request, nil)
http.finish

But http.start returns "SocketError: getaddrinfo: no address associated
with
hostname." always. Is there a command like geturl in the net/http package?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,196
Latest member
ScottChare

Latest Threads

Top