Class: XMLRPC::ModRubyServer
- Inherits:
-
BasicServer
- Object
- BasicServer
- XMLRPC::ModRubyServer
- Defined in:
- lib/xmlrpc/server.rb
Overview
Implements a XML-RPC server, which works with Apache mod_ruby.
Use it in the same way as XMLRPC::CGIServer!
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
-
#initialize(*a) ⇒ ModRubyServer
constructor
Creates a new XMLRPC::ModRubyServer instance.
-
#serve ⇒ Object
Call this after you have added all you handlers to the server.
Methods inherited from BasicServer
#add_handler, #add_introspection, #add_multicall, #get_default_handler, #get_service_hook, #process, #set_default_handler, #set_service_hook
Methods included from ParseContentType
Methods included from ParserWriterChooseMixin
Constructor Details
#initialize(*a) ⇒ ModRubyServer
Creates a new XMLRPC::ModRubyServer instance.
All parameters given are by-passed to XMLRPC::BasicServer.new.
467 468 469 470 |
# File 'lib/xmlrpc/server.rb', line 467 def initialize(*a) @ap = Apache::request super(*a) end |
Instance Method Details
#serve ⇒ Object
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.
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'lib/xmlrpc/server.rb', line 476 def serve catch(:exit_serve) { header = {} @ap.headers_in.each {|key, value| header[key.capitalize] = value} length = header['Content-length'].to_i http_error(405, "Method Not Allowed") unless @ap.request_method == "POST" http_error(400, "Bad Request") unless parse_content_type(header['Content-type']).first == "text/xml" http_error(411, "Length Required") unless length > 0 # TODO: do we need a call to binmode? @ap.binmode data = @ap.read(length) http_error(400, "Bad Request") if data.nil? or data.bytesize != length http_write(process(data), 200, "Content-type" => "text/xml; charset=utf-8") } end |