lib/rmobio/client_info.rb in rmobio-1.1.4 vs lib/rmobio/client_info.rb in rmobio-1.1.5
- old
+ new
@@ -19,12 +19,12 @@
Some summary should go here
=end
#require 'rexml/document'
require 'open-uri'
-require 'hpricot'
-
+require 'hpricot'
+require 'rmobio/rxml/transformer_factory'
module Rmobio
module ClientInfo
#== checkClient
#=== The method checks the client type, version and family by analyzing the request header.
@@ -48,25 +48,29 @@
#== Return Codes
# The method returns the following instance varables:
# @client => 'xf' or 'html' or 'wap'
# params[] => array contains name/value pairs of all parameters from POST request
# @paramsdoc => POST request in xml (parsed by hpricot)
- #
+ # @xml => rxml transformer for the client type
# @client_version => '0.6' or '0.8'
#
def checkClient
logger.debug('checkClient http_accept header:')
logger.debug(request.env['HTTP_ACCEPT'])
if request.env['HTTP_MOBIO_AGENT'] or request.env['HTTP_ACCEPT']=~/application\/pxml/
- @client="xf"
+ @client="xf"
elsif ((request.env['HTTP_ACCEPT']=~/wml/) ||
(request.env['HTTP_ACCEPT']=~/wap/) )
- @client="wap"
+ @client="wap"
+ elsif (request.env['HTTP_ACCEPT']=~/application\/xhtml/)
+ @client = "xhtml"
else
- @client="html"
+ @client="html"
end
-
+ # Get the rxml transformer for the client type
+ @xml = TransformerFactory::get_transformer(@client)
+
if @client == "xf"
headers.delete("Cache-Control")
headers['Content-Type']="application/mform"
@body = request.body.read.to_s if request.body
if request.env['REQUEST_METHOD'] == "POST" and @body
\ No newline at end of file