Class: XMLRPC::RackApplication

Inherits:
BasicServer show all
Defined in:
lib/xmlrpc/server.rb

Overview

Implements a XML-RPC application, which works with Rack

Constant Summary

Constants inherited from BasicServer

BasicServer::ERR_MC_EXPECTED_STRUCT, BasicServer::ERR_MC_MISSING_METHNAME, BasicServer::ERR_MC_MISSING_PARAMS, BasicServer::ERR_MC_RECURSIVE_CALL, BasicServer::ERR_MC_WRONG_PARAM, BasicServer::ERR_MC_WRONG_PARAM_PARAMS, BasicServer::ERR_METHOD_MISSING, BasicServer::ERR_UNCAUGHT_EXCEPTION

Instance Method Summary collapse

Methods inherited from BasicServer

#add_handler, #add_introspection, #add_multicall, #get_default_handler, #get_service_hook, #initialize, #process, #set_default_handler, #set_service_hook

Methods included from ParseContentType

#parse_content_type

Methods included from ParserWriterChooseMixin

#set_parser, #set_writer

Constructor Details

This class inherits a constructor from XMLRPC::BasicServer

Instance Method Details

#call(env) ⇒ Object

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



464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/xmlrpc/server.rb', line 464

def call(env)
  length = env['CONTENT_LENGTH'].to_i

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

  req = Rack::Request.new(env)
  data = req.body.read(length)

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

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