Repository: stigok/ruterstop

Issue:
Returner text/plain fra server
Nå er det text/html

```
HTTP/1.0 200 OK
Date: Fri, 17 Jan 2020 22:50:33 GMT
Server: WSGIServer/0.2 CPython/3.7.5
Content-Length: 88
Content-Type: text/html; charset=UTF-8

25 Furuset T    3 min
31 Grorud T     8 min
31 Fornebu      9 min
31 Tonsenhagen 14 min
```

Discussion:

Patch:
diff --git a/ruterstop/__init__.py b/ruterstop/__init__.py
index 7217385..cfb9f42 100644
--- a/ruterstop/__init__.py
+++ b/ruterstop/__init__.py
@@ -45,13 +45,13 @@ ENTUR_GRAPHQL_QUERY = """
 webapp = bottle.Bottle()
 
 def not_found_error_handler(res):
-    res.content_type = "text/plain"
+    res.set_header("Content-Type", "text/plain")
     return "Ugyldig stoppested"
 
 webapp.error(code=404)(not_found_error_handler)
 
 def default_error_handler(res):
-    res.content_type = "text/plain"
+    res.set_header("Content-Type", "text/plain")
     return "Feil på serveren"
 
 webapp.default_error_handler = default_error_handler
@@ -152,6 +152,7 @@ def serve_departures(stop_id):
         kw["grouped"] = True
 
     deps = get_departures(stop_id=stop_id)
+    bottle.response.set_header("Content-Type", "text/plain")
     return format_departure_list(deps, **kw)
 
 


Test patch:
diff --git a/ruterstop/tests/test_webapp.py b/ruterstop/tests/test_webapp.py
index 24d4175..ab82f79 100644
--- a/ruterstop/tests/test_webapp.py
+++ b/ruterstop/tests/test_webapp.py
@@ -19,6 +19,7 @@ class WebAppTestCase(TestCase):
     @patch("ruterstop.get_departures", return_value=dict(a="foo"))
     def test_calls_api_on_proper_path(self, get_mock, format_mock):
         res = self.app.get("/1234")
+        self.assertEqual(res.content_type, "text/plain")
         get_mock.assert_called_once_with(stop_id=1234)
         format_mock.assert_called_once_with(dict(a="foo"))