From 9b4a24c676a37cef0f165396048fd574c8dd0700 Mon Sep 17 00:00:00 2001 From: bcoles Date: Tue, 27 Dec 2011 19:37:57 +1030 Subject: [PATCH] Fixed content-type for .json files Content-type is now 'application/json' --- extensions/admin_ui/classes/httpcontroller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/admin_ui/classes/httpcontroller.rb b/extensions/admin_ui/classes/httpcontroller.rb index efe113d88..3517b8f7c 100644 --- a/extensions/admin_ui/classes/httpcontroller.rb +++ b/extensions/admin_ui/classes/httpcontroller.rb @@ -76,11 +76,14 @@ module AdminUI template_ui = "#{$root_dir}/extensions/admin_ui/controllers/#{class_s}/#{function_name}.html" @eruby = Erubis::FastEruby.new(File.read(template_ui)) if File.exists? template_ui # load the template file @body = @eruby.result(binding()) if not @eruby.nil? # apply template and set the response - + + # set appropriate content-type 'application/json' for .json files + @headers['Content-Type']='application/json; charset=UTF-8' if request.path =~ /\.json$/ + # set content type if @headers['Content-Type'].nil? @headers['Content-Type']='text/html; charset=UTF-8' # default content and charset type for all pages - @headers['Content-Type']='application/json; charset=UTF-8' if request.path =~ /.json$/ + @headers['Content-Type']='application/json; charset=UTF-8' if request.path =~ /\.json$/ end end