Method deprecated or moved
This method is deprecated or moved on the latest stable version.
The last existing version (v2_1_10) is shown here.
serve(io)
private
Handles the HTTP request and writes the response back to the client,
io.
If an Exception is raised while handling the
request, the client will receive a 500 “Internal Server Error” message.
Show source
def serve(io)
unless @handler.ip_auth_handler(io)
io << http_resp(403, "Forbidden")
return
end
if io.gets =~ /^(\S+)\s+(\S+)\s+(\S+)/
request = Request.new(io, $1, $2, $3)
else
io << http_resp(400, "Bad Request")
return
end
while (line=io.gets) !~ /^(\n|\r)/
if line =~ /^([\w-]+):\s*(.*)$/
request.header[$1] = $2.strip
end
end
io.binmode
response = Response.new
@handler.request_handler(request, response)
io << http_resp(response.status, response.status_message,
response.header, response.body)
rescue Exception
io << http_resp(500, "Internal Server Error")
end