WEBrick::HTTPServlet::AbstractServlet
# File lib/soap/rpc/soaplet.rb, line 46 46: def initialize(router = nil) 47: @router = router || ::SOAP::RPC::Router.new(self.class.name) 48: @options = {} 49: @authenticator = nil 50: @config = {} 51: end
for backward compatibility
# File lib/soap/rpc/soaplet.rb, line 59 59: def add_servant(obj, namespace) 60: @router.add_rpc_servant(obj, namespace) 61: end
# File lib/soap/rpc/soaplet.rb, line 63 63: def allow_content_encoding_gzip=(allow) 64: @options[:allow_content_encoding_gzip] = allow 65: end
for backward compatibility
# File lib/soap/rpc/soaplet.rb, line 54 54: def app_scope_router 55: @router 56: end
# File lib/soap/rpc/soaplet.rb, line 79 79: def do_GET(req, res) 80: res.header['Allow'] = 'POST' 81: raise WEBrick::HTTPStatus::MethodNotAllowed, "GET request not allowed" 82: end
# File lib/soap/rpc/soaplet.rb, line 84 84: def do_POST(req, res) 85: logger.debug { "SOAP request: " + req.body } if logger 86: if @authenticator 87: @authenticator.authenticate(req, res) 88: # you can check authenticated user with SOAP::RPC::SOAPlet.user 89: end 90: begin 91: conn_data = ::SOAP::StreamHandler::ConnectionData.new 92: setup_req(conn_data, req) 93: @router.external_ces = @options[:external_ces] 94: Mapping.protect_threadvars(:SOAPlet) do 95: SOAPlet.user = req.user 96: SOAPlet.cookies = req.cookies 97: conn_data = @router.route(conn_data) 98: setup_res(conn_data, req, res) 99: end 100: rescue Exception => e 101: conn_data = @router.create_fault_response(e) 102: res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR 103: res.body = conn_data.send_string 104: res['content-type'] = conn_data.send_contenttype || "text/xml" 105: end 106: if res.body.is_a?(IO) 107: res.chunked = true 108: logger.debug { "SOAP response: (chunked response not logged)" } if logger 109: else 110: logger.debug { "SOAP response: " + res.body } if logger 111: end 112: end
Servlet interfaces for WEBrick.
# File lib/soap/rpc/soaplet.rb, line 70 70: def get_instance(config, *options) 71: @config = config 72: self 73: end
# File lib/soap/rpc/soaplet.rb, line 187 187: def encode_gzip(req, outstring) 188: unless encode_gzip?(req) 189: return nil 190: end 191: begin 192: ostream = StringIO.new 193: gz = Zlib::GzipWriter.new(ostream) 194: gz.write(outstring) 195: ostream.string 196: ensure 197: gz.close 198: end 199: end
# File lib/soap/rpc/soaplet.rb, line 201 201: def encode_gzip?(req) 202: @options[:allow_content_encoding_gzip] and defined?(::Zlib) and 203: req['accept-encoding'] and 204: req['accept-encoding'].split(/,\s*/).include?('gzip') 205: end
# File lib/soap/rpc/soaplet.rb, line 145 145: def logger 146: @config[:Logger] 147: end
# File lib/soap/rpc/soaplet.rb, line 178 178: def parse_soapaction(soapaction) 179: if !soapaction.nil? and !soapaction.empty? 180: if /^"(.+)"$/ =~ soapaction 181: return $1 182: end 183: end 184: nil 185: end
# File lib/soap/rpc/soaplet.rb, line 149 149: def setup_req(conn_data, req) 150: conn_data.receive_string = req.body 151: conn_data.receive_contenttype = req['content-type'] 152: conn_data.soapaction = parse_soapaction(req.meta_vars['HTTP_SOAPACTION']) 153: end
# File lib/soap/rpc/soaplet.rb, line 155 155: def setup_res(conn_data, req, res) 156: res['content-type'] = conn_data.send_contenttype 157: cookies = SOAPlet.cookies 158: unless cookies.empty? 159: res['set-cookie'] = cookies.collect { |cookie| cookie.to_s } 160: end 161: if conn_data.is_nocontent 162: res.status = WEBrick::HTTPStatus::RC_ACCEPTED 163: res.body = '' 164: return 165: end 166: if conn_data.is_fault 167: res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR 168: end 169: if outstring = encode_gzip(req, conn_data.send_string) 170: res['content-encoding'] = 'gzip' 171: res['content-length'] = outstring.size 172: res.body = outstring 173: else 174: res.body = conn_data.send_string 175: end 176: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.