lib/rmobio/utils.rb in rmobio-1.1.9 vs lib/rmobio/utils.rb in rmobio-1.1.10
- old
+ new
@@ -87,11 +87,11 @@
end
if name=~ /.png$/
# for now hardcode the image directory
filePath = File::join RAILS_ROOT, 'public/images/', name
- file = File.new(filePath,"r")
+ file = File.new(filePath,"rb")
filecontents = file.read(File.size(filePath))
file.close()
headers["Content-Type"] = "image/png"
@@ -194,9 +194,32 @@
url = ''
end
logger.debug('back url ' + key + ': ' + url)
"<burl>" + url + "</burl>"
end # end backurl_xml
+
+ # set_request_context
+ # This filter checks for the existence of a "mobio-context" header.
+ # If the header exists, then it is prepended to the request's uri. The flow
+ # is the following:
+ #
+ #
+ # A request is made to the server which contains a mobio-context header with
+ # a value of "mycustomcontext" to "/news"
+ #
+ # After applying the filter, the request uri would become
+ #
+ # "/mycustomcontext/news"
+ #
+ # If no header exists, the filter acts as a pass-through.
+ #
+ def set_request_context
+ if request.env['HTTP_MOBIO-CONTEXT'] and not request.env['HTTP_MOBIO-CONTEXT'] == ''
+ request.request_uri = '/' + request.env['HTTP_MOBIO-CONTEXT'] + request.request_uri
+ RAILS_DEFAULT_LOGGER.debug 'Utils: Setting the uri to: "' +
+ request.request_uri + '" for the current request.' unless not defined? RAILS_DEFAULT_LOGGER
+ end
+ end
def logHeaders
logger.debug( "Logging Headers...")
request.env.keys.each do |header|
logger.debug( header.to_s + ': ' + request.env[header].to_s)
\ No newline at end of file