Fix handling of content-types that also contain the encoding

This commit is contained in:
2012-09-30 21:57:58 +02:00
parent d88ad2eb20
commit d4d02e3e77
2 changed files with 27 additions and 2 deletions

View File

@@ -36,7 +36,7 @@ module RemoteStorage
object = data_bucket.get("#{user}:#{category}:#{key}")
headers["Content-Type"] = object.content_type
headers["Last-Modified"] = object.last_modified.to_s(:rfc822)
case object.content_type
case object.content_type[/^[^;\s]+/]
when "application/json"
return object.data.to_json
else
@@ -62,7 +62,7 @@ module RemoteStorage
def put_data(user, category, key, data, content_type=nil)
object = data_bucket.new("#{user}:#{category}:#{key}")
object.content_type = content_type || "text/plain; charset=utf-8"
data = JSON.parse(data) if content_type == "application/json"
data = JSON.parse(data) if content_type[/^[^;\s]+/] == "application/json"
if serializer_for(object.content_type)
object.data = data
else