Repository: jazzband/django-ical (language: python)

Issue:
Content Type should contain `;`instead of `,`
In pull request responding to the #33, you added:
        response = HttpResponse(content_type='text/calendar, text/x-vcalendar, application/hbs-vcs')

The correct syntax should be:
        response = HttpResponse(content_type='text/calendar; text/x-vcalendar; application/hbs-vcs')

In the current situation, it does not work everywhere...


Discussion / hints:
Hi @PabloLeCrapaud! Would you be interested in opening a PR including the fix for the content type?
Of course! But I have to confess I'm not sure that my proposal was correct... In my case I had to replace it by content_type='text/calendar' only, so I'm not sure the problem was the `;`. I'll check and open a PR if needed... 
Content-Type header does not seem to allow multiple values in the response, although a client can define multiple accepted media types. The server could return a suitable response with requested Content-Type if it can.

- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept (request)
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type (response)

Should we just define the Content-Type as it was previously defined as `feedgen.mime_type`? 

Fix patch:
diff --git a/django_ical/views.py b/django_ical/views.py
index 5b7225a..51960df 100644
--- a/django_ical/views.py
+++ b/django_ical/views.py
@@ -78,10 +78,10 @@ def __call__(self, request, *args, **kwargs):
             obj = self.get_object(request, *args, **kwargs)
         except ObjectDoesNotExist:
             raise Http404("Feed object does not exist.")
+
         feedgen = self.get_feed(obj, request)
-        response = HttpResponse(
-            content_type="text/calendar, text/x-vcalendar, application/hbs-vcs"
-        )
+        response = HttpResponse(content_type=feedgen.mime_type)
+
         if hasattr(self, "item_pubdate") or hasattr(self, "item_updateddate"):
             # if item_pubdate or item_updateddate is defined for the feed, set
             # header so as ConditionalGetMiddleware is able to send 304 NOT MODIFIED


Test patch:
diff --git a/django_ical/tests/test_feed.py b/django_ical/tests/test_feed.py
index e91fae0..30a0e85 100644
--- a/django_ical/tests/test_feed.py
+++ b/django_ical/tests/test_feed.py
@@ -413,7 +413,7 @@ def test_file_type(self):
         self.assertIn("Content-Type", response)
         self.assertEqual(
             response["content-type"],
-            "text/calendar, text/x-vcalendar, application/hbs-vcs",
+            "text/calendar; charset=utf8",
         )
 
     def test_file_header(self):