15 May 11:21
Re: Webrick HTTP Errors?
From: GOTO Kentaro <gotoken <at> gmail.com>
Subject: Re: Webrick HTTP Errors?
Newsgroups: gmane.comp.lang.ruby.general
Date: 2008-05-15 09:21:41 GMT
Subject: Re: Webrick HTTP Errors?
Newsgroups: gmane.comp.lang.ruby.general
Date: 2008-05-15 09:21:41 GMT
Use raise to set status in WEBrick. For example,
require "webrick"
s = WEBrick::HTTPServer.new(:Port => 2000)
s.mount_proc("/"){|req, res|
res.body = "ok"
raise WEBrick::HTTPStatus::OK
}
s.mount_proc("/404"){|req, res|
raise WEBrick::HTTPStatus::NotFound
}
trap("INT"){s.shutdown}
s.start
This server returns 404 for http://localhost:2000/404
but return 200 for other urls.
HTH,
Gotoken
On Thu, May 15, 2008 at 4:39 PM, Christian Kerth
<christian.kerth <at> dynamicmedia.at> wrote:
> Hey
>
> How do i set the HTTP Error Code Header when using webrick.
>
> I found the response.set_error function. What do i need to pass there to
> e.g. set a http 404 error?
>
> thx
> --
> Posted via http://www.ruby-forum.com/.
>
>
RSS Feed