diff options
Diffstat (limited to 'lib/soap/rpc/cgistub.rb')
-rw-r--r-- | lib/soap/rpc/cgistub.rb | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/lib/soap/rpc/cgistub.rb b/lib/soap/rpc/cgistub.rb index 2377f343b5..4fc8b98cee 100644 --- a/lib/soap/rpc/cgistub.rb +++ b/lib/soap/rpc/cgistub.rb @@ -40,7 +40,6 @@ class CGIStub < Logger::Application @method = ENV['REQUEST_METHOD'] @size = ENV['CONTENT_LENGTH'].to_i || 0 @contenttype = ENV['CONTENT_TYPE'] - @charset = nil @soapaction = ENV['HTTP_SOAPAction'] @source = stream @body = nil @@ -48,7 +47,6 @@ class CGIStub < Logger::Application def init validate - @charset = StreamHandler.parse_media_type(@contenttype) @body = @source.read(@size) self end @@ -61,8 +59,8 @@ class CGIStub < Logger::Application @soapaction end - def charset - @charset + def contenttype + @contenttype end def to_s @@ -142,8 +140,8 @@ class CGIStub < Logger::Application @router.add_method(receiver, qname, nil, name, param_def) end - def route(request_string, charset) - @router.route(request_string, charset) + def route(conn_data) + @router.route(conn_data) end def create_fault_response(e) @@ -157,32 +155,30 @@ private httpversion = WEBrick::HTTPVersion.new('1.0') @response = WEBrick::HTTPResponse.new({:HTTPVersion => httpversion}) + conn_data = nil begin log(INFO) { "Received a request from '#{ @remote_user }@#{ @remote_host }'." } # SOAP request parsing. @request = SOAPRequest.new.init @response['Status'] = 200 - req_charset = @request.charset - req_string = @request.dump - log(DEBUG) { "XML Request: #{req_string}" } - res_string, is_fault = route(req_string, req_charset) - log(DEBUG) { "XML Response: #{res_string}" } - - @response['Cache-Control'] = 'private' - if req_charset - @response['content-type'] = "#{@mediatype}; charset=\"#{req_charset}\"" - else - @response['content-type'] = @mediatype - end - if is_fault + conn_data = ::SOAP::StreamHandler::ConnectionData.new + conn_data.receive_string = @request.dump + conn_data.receive_contenttype = @request.contenttype + log(DEBUG) { "XML Request: #{conn_data.receive_string}" } + conn_data = route(conn_data) + log(DEBUG) { "XML Response: #{conn_data.send_string}" } + if conn_data.is_fault @response['Status'] = 500 end - @response.body = res_string + @response['Cache-Control'] = 'private' + @response.body = conn_data.send_string + @response['content-type'] = conn_data.send_contenttype rescue Exception - res_string = create_fault_response($!) + conn_data = create_fault_response($!) @response['Cache-Control'] = 'private' - @response['content-type'] = @mediatype @response['Status'] = 500 + @response.body = conn_data.send_string + @response['content-type'] = conn_data.send_contenttype || @mediatype ensure buf = '' @response.send_response(buf) |