# XMLRPC::WEBrickServlet (Class)

In: | xmlrpc/server.rb
Parent: | BasicServer

## Methods

get_instance new require_path_info? service

## Public Class methods

new(*a)

[Source]

    # File xmlrpc/server.rb, line 779
      def initialize(*a)
        super
        require "webrick/httpstatus"
      end

## Public Instance methods

require_path_info?()

deprecated from WEBrick/1.2.2. but does not break anything.

[Source]

    # File xmlrpc/server.rb, line 786
      def require_path_info?
        false
      end

get_instance(config, *options)

[Source]

    # File xmlrpc/server.rb, line 790
      def get_instance(config, *options)
        # TODO: set config & options

        self
      end

service(request, response)

[Source]

    # File xmlrpc/server.rb, line 795
      def service(request, response)
        if request.request_method != "POST"
          raise HTTPStatus::MethodNotAllowed,
                "unsupported method `#{request.request_method}'."
        end

        if parse_content_type(request['Content-type']).first != "text/xml"
          raise HTTPStatus::BadRequest
        end

        length = (request['Content-length'] || 0).to_i

        raise HTTPStatus::LengthRequired unless length > 0

        data = request.body

        if data.nil? or data.size != length
          raise HTTPStatus::BadRequest
        end

        resp = process(data)
        if resp.nil? or resp.size <= 0
          raise HTTPStatus::InternalServerError
        end

        response.status = 200
        response['Content-Length'] = resp.size
        response['Content-Type']   = "text/xml"
        response.body = resp
      end

[Validate]