Skip to content

Commit 84d4ac2

Browse files
authored
Remove ModRubyServer (#59)
And add the missing Rack application to the docs (#56) Closes #57 --------- Co-authored-by: Herwin <herwinw@users.noreply.github.com>
1 parent 9d48e11 commit 84d4ac2

File tree

2 files changed

+1
-77
lines changed

2 files changed

+1
-77
lines changed

lib/xmlrpc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
# * Server
4545
# * Standalone XML-RPC server
4646
# * CGI-based (works with FastCGI)
47-
# * Apache mod_ruby server
47+
# * Rack application
4848
# * WEBrick servlet
4949
#
5050
# * Client

lib/xmlrpc/server.rb

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -456,82 +456,6 @@ def http_write(body, header)
456456
end
457457

458458

459-
# Implements a XML-RPC server, which works with Apache mod_ruby.
460-
#
461-
# Use it in the same way as XMLRPC::CGIServer!
462-
class ModRubyServer < BasicServer
463-
464-
# Creates a new XMLRPC::ModRubyServer instance.
465-
#
466-
# All parameters given are by-passed to XMLRPC::BasicServer.new.
467-
def initialize(*a)
468-
@ap = Apache::request
469-
super(*a)
470-
end
471-
472-
# Call this after you have added all you handlers to the server.
473-
#
474-
# This method processes a XML-RPC method call and sends the answer
475-
# back to the client.
476-
def serve
477-
catch(:exit_serve) {
478-
header = {}
479-
@ap.headers_in.each {|key, value| header[key.capitalize] = value}
480-
481-
length = header['Content-length'].to_i
482-
483-
http_error(405, "Method Not Allowed") unless @ap.request_method == "POST"
484-
http_error(400, "Bad Request") unless parse_content_type(header['Content-type']).first == "text/xml"
485-
http_error(411, "Length Required") unless length > 0
486-
487-
# TODO: do we need a call to binmode?
488-
@ap.binmode
489-
data = @ap.read(length)
490-
491-
http_error(400, "Bad Request") if data.nil? or data.bytesize != length
492-
493-
http_write(process(data), 200, "Content-type" => "text/xml; charset=utf-8")
494-
}
495-
end
496-
497-
498-
private
499-
500-
def http_error(status, message)
501-
err = "#{status} #{message}"
502-
msg = <<-"MSGEND"
503-
<html>
504-
<head>
505-
<title>#{err}</title>
506-
</head>
507-
<body>
508-
<h1>#{err}</h1>
509-
<p>Unexpected error occurred while processing XML-RPC request!</p>
510-
</body>
511-
</html>
512-
MSGEND
513-
514-
http_write(msg, status, "Status" => err, "Content-type" => "text/html")
515-
throw :exit_serve # exit from the #serve method
516-
end
517-
518-
def http_write(body, status, header)
519-
h = {}
520-
header.each {|key, value| h[key.to_s.capitalize] = value}
521-
h['Status'] ||= "200 OK"
522-
h['Content-length'] ||= body.bytesize.to_s
523-
524-
h.each {|key, value| @ap.headers_out[key] = value }
525-
@ap.content_type = h["Content-type"]
526-
@ap.status = status.to_i
527-
@ap.send_http_header
528-
529-
@ap.print body
530-
end
531-
532-
end
533-
534-
535459
# Implements a XML-RPC application, which works with Rack
536460
class RackApplication < BasicServer
537461

0 commit comments

Comments
 (0)