Method: XMLRPC::CGIServer#serve

Defined in:
lib/xmlrpc/server.rb

#serveObject

Call this after you have added all you handlers to the server.

This method processes a XML-RPC method call and sends the answer back to the client.



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/xmlrpc/server.rb', line 404

def serve
  catch(:exit_serve) {
    length = ENV['CONTENT_LENGTH'].to_i

    http_error(405, "Method Not Allowed") unless ENV['REQUEST_METHOD'] == "POST"
    http_error(400, "Bad Request")        unless parse_content_type(ENV['CONTENT_TYPE']).first == "text/xml"
    http_error(411, "Length Required")    unless length > 0

    # TODO: do we need a call to binmode?
    $stdin.binmode if $stdin.respond_to? :binmode
    data = $stdin.read(length)

    http_error(400, "Bad Request")        if data.nil? or data.bytesize != length

    http_write(process(data), "Content-type" => "text/xml; charset=utf-8")
  }
end