Forum: Ruby http#get return 404 error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Lian Yan (Guest)
on 2006-06-13 18:03
(Received via mailing list)
Hi,

I tried to use

http#get("http://www.mla.org/about")

to obtain the page, but it returns a 404 error. However, using browser
works fine.

I guess the server uses "struts" or similar framework. Would anyboby
tell me how to solve this problem.

Regards

Lian
ts (Guest)
on 2006-06-13 18:22
(Received via mailing list)
>>>>> "L" == Lian Yan <lyan@univmail.cis.mcmaster.ca> writes:

L> I guess the server uses "struts" or similar framework. Would anyboby
L> tell me how to solve this problem.

 Just display the page which is given and you'll see that it's the same
than
 the page retrieved by your browser



Guy Decoux
Jacob Fugal (Guest)
on 2006-06-13 18:41
(Received via mailing list)
On 6/13/06, Lian Yan <lyan@univmail.cis.mcmaster.ca> wrote:
> I tried to use
>
> http#get("http://www.mla.org/about")
>
> to obtain the page, but it returns a 404 error. However, using browser
> works fine.

Like Guy, I'm able to get the page as so[1]:

  require 'net/http'
  require 'uri'

  url = URI.parse('http://www.mla.org/about')
  res = Net::HTTP.start(url.host, url.port) {|http|
    http.get('/index.html')
  }
  puts res.body

I do, however, find it odd that trying to use wget does indeed result in
a 404:

  $ wget http://www.mla.org/about
  --10:52:42--  http://www.mla.org/about
             => `about'
  Resolving www.mla.org... 209.11.11.22
  Connecting to www.mla.org|209.11.11.22|:80... connected.
  HTTP request sent, awaiting response... 404 Not found
  10:52:43 ERROR 404: Not found.

Odd, that.

Jacob Fugal

[1] I wasn't sure what "http#get" you were referring to, so I chose
the most applicable example from the net/http documentation, net/http
being part of the standard library. If this doesn't match your usage,
please explain more about which library you are using, particularly
with a code example.
ts (Guest)
on 2006-06-13 18:45
(Received via mailing list)
>>>>> "J" == Jacob Fugal <lukfugl@gmail.com> writes:

J> I do, however, find it odd that trying to use wget does indeed result
in
J> a 404:

 The server returns 404 : just ignore it :-)

Guy Decoux
This topic is locked and can not be replied to.