Index: [Article Count Order] [Thread]

Date:  Tue, 16 Apr 2002 23:29:04 +1200
From:  Holden Glova <dsafari@xtra.co.nz>
Subject:  [webricken:93] WEBrick does immediate redirect
To:  webricken@notwork.org
Message-Id:  <20020416112754.YRAQ10762.mta1-rme.xtra.co.nz@there>
X-Mail-Count: 00093

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello all,

I have something wierd going on with this little example. For some odd reason 
I get a redirect immediately after doing a GET on a resource.

Here is my server:
#!/usr/bin/env ruby -w

require 'webrick'
require 'getopts'

require 'hello'


s = WEBrick::HTTPServer.new(
  :Port         => 2000,
  :Logger       => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG)
)

s.mount('/hello', HelloServlet)

trap("INT") { s.shutdown }
s.start


Here is my HelloServlet:
require 'webrick'
include WEBrick

class HelloServlet < HTTPServlet::AbstractServlet
  extend ERbMethod

  def do_GET(req, res)
    #puts req.query
    name     = req.query['name']
    #puts name
    #greeting = get_greeting(req['language'])

    res['Content-Type'] = 'text/xml'
    res.body = %Q|<?xml version="1.0" encoding="UTF-8"?>\n|
    res.body << %Q|<greet>\n|
    #res.body << %Q|<greeting>#{greeting}</greeting>\n|
    res.body << %Q|<name>#{name}</name>\n|
    res.body << %Q|</greet>\n|
  end


  def get_greeting(language)

  end
end


Here is the logs from WEBrick:
[2002-04-16 23:18:14] DEBUG accept: 127.0.0.1:36212

[2002-04-16 23:18:14] INFO  127.0.0.1 "GET /hello?name=Holden HTTP/1.1" 301 
44 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020214"

[2002-04-16 23:18:15] INFO  127.0.0.1 "GET /hello/ HTTP/1.1" 200 70 "-" 
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020214"

[2002-04-16 23:18:45] INFO  127.0.0.1 "" 408 0 "-" "-"

[2002-04-16 23:18:45] DEBUG close: 127.0.0.1:36212


As the logs show I want to request that HelloServlet do some work with the 
supplied parameter and return me some XML.

This must be something so fundamental that I am doing wrong, not sure what 
though. Many thanks in advance for any help provided.

- -- 
Signed,
Holden Glova
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8vAsC+mF116Lw2cQRAkRYAJ4mv/C7lCgTafJFrHqvj+s4V8GCqwCfTheQ
Q3yp8V7dD4+U0kJkRSVkOXk=
=zBdS
-----END PGP SIGNATURE-----