Fix adding dependency package to environment with debreach

When using the debreach random comment middleware with Django,
the API response when adding a dependency package to an
environment would end up with a html-style comment at the end of
the response, which would then fail JSON parsing by the dashboard.

To prevent debreach from adding the random data, the content type
needs to be something other than text/html. The response output
itself isn't really JSON so switching to JsonResponse doesn't
work becuase the content isn't a dict, so just use text/plain
instead.

Change-Id: Ie710487d865344c9a5cd71d4dec3bf927cfabf40
This commit is contained in:
Andy Botting 2019-08-07 14:30:59 +10:00
parent 3342531a81
commit be8d112153
1 changed files with 3 additions and 3 deletions

View File

@ -419,9 +419,9 @@ class Wizard(generic_views.PageTitleMixin, views.ModalFormMixin, LazyWizard):
# that way until we move here from django Wizard to horizon workflow
if views.ADD_TO_FIELD_HEADER in self.request.META:
field_id = self.request.META[views.ADD_TO_FIELD_HEADER]
response = http.HttpResponse(json.dumps(
[obj_id, html.escape(obj_name)]
))
response = http.HttpResponse(
json.dumps([obj_id, html.escape(obj_name)]),
content_type='text/plain')
response["X-Horizon-Add-To-Field"] = field_id
return response
else: