[Nitro] HTTP verbs and headers

Lars Olsson lasso at lassoweb.se
Thu Mar 29 05:04:01 EDT 2007


Hi list!

I'm not sure this is a Nitro problem, but I'm seeing a somewhat
unexspected behaviour when playing around with Nitro (using Apache
Proxy/webrick adapter).

I used a small program to test various request methods against my Nitro app:

require 'net/http'

ADDRESS = 'localhost'
PORT = 80
RESOURCE = '/'

req = Net::HTTP.new(ADDRESS, PORT)

begin
    print "GET #{ADDRESS}#{RESOURCE}..."
    res = req.get(RESOURCE)
    puts "#{res.code} #{res.message}"
    print "HEAD #{ADDRESS}#{RESOURCE}..."
    res = req.head(RESOURCE)
    puts "#{res.code} #{res.message}"
    print "POST #{ADDRESS}#{RESOURCE}..."
    res = req.post(RESOURCE, 'data')
    puts "#{res.code} #{res.message}"
    print "PUT #{ADDRESS}#{RESOURCE}..."
    res = req.put(RESOURCE, 'data')
    puts "#{res.code} #{res.message}"
    print "DELETE #{ADDRESS}#{RESOURCE}..."
    res = req.delete(RESOURCE)
    puts "#{res.code} #{res.message}"
rescue Exception => err
    puts err.message
end

The program just requests 'http://localhost/' using different HTTP verbs
and prints the returned status codes. All requests return '200 OK'.
According to the HTTP specs I should get a '405 Method Not Allowed' when
using 'unallowed' verbs. I'm not actually sure if Nitro is responsible for
the headers (might be set by webrick/mongrel), but maybe it is fixable.
(For 'correct' behaviour, please test against 'www.w3.org').

Any comments or suggestions?


Sincerely

/lasso



More information about the Nitro-general mailing list