Class | XMLRPC::WEBrickServlet
In: | xmlrpc/server.rb
Parent: | BasicServer

### Methods

get_instance get_valid_ip new require_path_info? service set_valid_ip

### Public Class methods

new(*a)

[Source]

    # File xmlrpc/server.rb, line 708
      def initialize(*a)
        super
        require "webrick/httpstatus"
        @valid_ip = nil
      end

### Public Instance methods

get_instance(config, *options)

[Source]

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

get_valid_ip()

[Source]

    # File xmlrpc/server.rb, line 733
      def get_valid_ip
        @valid_ip
      end

require_path_info?()

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

[Source]

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

service(request, response)

[Source]

    # File xmlrpc/server.rb, line 737
      def service(request, response)

        if @valid_ip
          raise WEBrick::HTTPStatus::Forbidden unless @valid_ip.any? { |ip| request.peeraddr[3] =~ ip }
        end

        if request.request_method != "POST"
          raise WEBrick::HTTPStatus::MethodNotAllowed,
                "unsupported method `#{request.request_method}'."
        end

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

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

        raise WEBrick::HTTPStatus::LengthRequired unless length > 0

        data = request.body

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

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

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

set_valid_ip(*ip_addr)

[Source]

    # File xmlrpc/server.rb, line 725
      def set_valid_ip(*ip_addr)
        if ip_addr.size == 1 and ip_addr[0].nil?
          @valid_ip = nil
        else
          @valid_ip = ip_addr
        end
      end

[Validate]