From 064fcab903e107bc4f4586ceb26e76def1cde118 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@ericsson.com>
Date: Fri, 5 Apr 2024 10:11:09 +0200
Subject: [PATCH] v0.4 added Vagrant for local debugging

---
 Vagrantfile            | 2 +-
 flask_minijson.py      | 5 ++++-
 setup.cfg              | 2 +-
 tests/test_minijson.py | 2 ++
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/Vagrantfile b/Vagrantfile
index 2d91c67..fcb67e1 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -16,7 +16,7 @@ Vagrant.configure("2") do |config|
 
     # Python
     apt-get install -y htop curl python3-pip build-essential python3 python3-setuptools
-    sudo pip3 install --upgrade pip setuptools
+    sudo pip3 install --upgrade pip setuptools Cython
 
     # Install deps
     sudo pip3 install -r /vagrant/requirements.txt
diff --git a/flask_minijson.py b/flask_minijson.py
index ea8ea4a..615b5b0 100644
--- a/flask_minijson.py
+++ b/flask_minijson.py
@@ -10,13 +10,16 @@ except ImportError:
     from flask_json import FlaskJSONRequest as JsonRequest
 
 
+MINIJSON_MIME = ('application/minijson', 'application/x-minijson')
+
+
 class MiniJSONRequest(JsonRequest):
     def get_json(self, force=False, silent=False, cache=True):
         """
         Return JSON data, if content type is application/minijson it will be loaded
         via minijson, else it will be loaded the normal way.
         """
-        if self.headers.get('Content-Type') == 'application/minijson':
+        if self.headers.get('Content-Type') in MINIJSON_MIME:
             return minijson.loads(self.get_data())
         else:
             return super().get_json(force, silent, cache)
diff --git a/setup.cfg b/setup.cfg
index 8f03cf9..a8781f7 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 # coding: utf-8
 [metadata]
-version = 0.3
+version = 0.4
 name = flask-minijson
 long_description = file: README.md
 long_description_content_type = text/markdown; charset=UTF-8
diff --git a/tests/test_minijson.py b/tests/test_minijson.py
index bdbfe4f..b2fa422 100644
--- a/tests/test_minijson.py
+++ b/tests/test_minijson.py
@@ -11,6 +11,8 @@ class TestMiniJSON(unittest.TestCase):
 
     def test_minijson(self):
         data = minijson.dumps({'1': '2'})
+        resp = self.client.post('/v1', data=data, headers={'Content-Type': 'application/x-minijson'})
+        self.assertEqual(resp.get_json(), {'status': 'ok'})
         resp = self.client.post('/v1', data=data, headers={'Content-Type': 'application/minijson'})
         self.assertEqual(resp.get_json(), {'status': 'ok'})
         resp = self.client.post('/v1', json={'1': '3'})
-- 
GitLab