From: marios <[email protected]>
Signed-off-by: marios <[email protected]> --- server/lib/cimi/helpers/cimi_helper.rb | 9 ++++++--- server/lib/cimi/models/errors.rb | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/server/lib/cimi/helpers/cimi_helper.rb b/server/lib/cimi/helpers/cimi_helper.rb index 3dd9501..5b7e91a 100644 --- a/server/lib/cimi/helpers/cimi_helper.rb +++ b/server/lib/cimi/helpers/cimi_helper.rb @@ -55,12 +55,15 @@ module CIMI def grab_content_type(request_content_type, request_body) case request_content_type - when /xml$/i then :xml - when /json$/i then :json - else guess_content_type(request_body) + when /xml$/ then :xml + when /json$/ then :json + else raise CIMI::Model::UnsupportedMediaType.new("Unsupported content type - only xml and json supported by CIMI") + #guess_content_type(request_body) end end + #not being used - was called from above grab_content_type + #decided to reject anything not xml || json def guess_content_type(request_body) xml = json = false body = request_body.read diff --git a/server/lib/cimi/models/errors.rb b/server/lib/cimi/models/errors.rb index 7c090ed..2d14144 100644 --- a/server/lib/cimi/models/errors.rb +++ b/server/lib/cimi/models/errors.rb @@ -33,6 +33,14 @@ module CIMI::Model end end + class UnsupportedMediaType < StandardError + attr_accessor :code + def initialize(msg="") + super(msg) + self.code=415 + end + end + class NotImplemented < StandardError attr_accessor :code -- 1.7.11.7
