Commits

Michael Granger committed 243c948

Use LibXML instead of Nokogiri for XML request type

Comments (0)

Files changed (2)

lib/mongrel2/xmlrequest.rb

 #!/usr/bin/ruby
 
-require 'nokogiri'
+require 'libxml'
 require 'loggability'
 
 require 'mongrel2/request' unless defined?( Mongrel2::Request )
 	def initialize( sender_id, conn_id, path, headers, body, raw=nil )
 		super
 		self.log.debug "Parsing XML request body"
-		@data = Nokogiri::XML( body )
+		@reader = LibXML::XML::Reader.string( body )
 	end
 
 
 	public
 	######
 
-	# The parsed request data (a Nokogiri::XML document)
-	attr_reader :data
+	# The parsed request data (a LibXML::Reader object)
+	attr_reader :reader
 
 
 end # class Mongrel2::XMLRequest

spec/mongrel2/xmlrequest_spec.rb

+#!/usr/bin/env ruby
+
+require_relative '../helpers'
+
+require 'rspec'
+
+require 'tnetstring'
+require 'tmpdir'
+require 'tempfile'
+
+require 'mongrel2'
+require 'mongrel2/xmlrequest'
+
+
+#####################################################################
+###	C O N T E X T S
+#####################################################################
+
+describe Mongrel2::XMLRequest do
+
+	let( :factory ) { Mongrel2::RequestFactory.new(route: '/form') }
+
+
+	it "can parse an XML request message" do
+
+		message = make_xml_request()
+		req = Mongrel2::Request.parse( message )
+
+		expect( req ).to be_a( Mongrel2::XMLRequest )
+		expect( req.sender_id ).to eq( TEST_UUID )
+		expect( req.conn_id ).to eq( TEST_ID )
+
+		expect( req.headers ).to be_a( Mongrel2::Table )
+		expect( req.headers['pattern'] ).to eq( TEST_XML_HEADERS['PATH'] )
+	end
+
+
+end
+