diff --git a/CHANGES.rst b/CHANGES.rst index 727bddfe7..2ad8e5cff 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,7 +16,9 @@ Changes: Fixes: ------ -- No change. +- Fix ``PROV`` endpoints returning multiple ``Content-Type`` headers + (default ``text/html`` inserted by ``webob.response.Response`` class onto top of the explicit one specified) + leading to inconsistent responses parsing and rendering across clients. .. _changes_6.1.0: diff --git a/tests/functional/test_job_provenance.py b/tests/functional/test_job_provenance.py index eafb7d980..a3dc3c422 100644 --- a/tests/functional/test_job_provenance.py +++ b/tests/functional/test_job_provenance.py @@ -99,6 +99,7 @@ def test_job_prov_json(self, queries, headers): prov_url = f"{self.job_url}/prov" resp = self.app.get(prov_url, params=queries, headers=headers) assert resp.status_code == 200 + assert len(list(filter(lambda header: header[0] == "Content-Type", resp.headerlist))) == 1 assert resp.content_type == ContentType.APP_JSON prov = resp.json assert "prefix" in prov @@ -113,6 +114,7 @@ def test_job_prov_xml(self, queries, headers): prov_url = f"{self.job_url}/prov" resp = self.app.get(prov_url, params=queries, headers=headers) assert resp.status_code == 200 + assert len(list(filter(lambda header: header[0] == "Content-Type", resp.headerlist))) == 1 assert resp.content_type in ContentType.ANY_XML prov = resp.text assert " Tuple[Optional[str], Optional[AnyContentType]] """ diff --git a/weaver/wps_restapi/jobs/utils.py b/weaver/wps_restapi/jobs/utils.py index e63fac5bf..6cbf6fbea 100644 --- a/weaver/wps_restapi/jobs/utils.py +++ b/weaver/wps_restapi/jobs/utils.py @@ -1451,8 +1451,7 @@ def get_job_prov_response(request): prov_body["error"] = "No such run ID for specified job provenance." prov_body["value"] = {"run_id": str(request.matchdict["run_id"])} prov_body["status"] = prov_err.code - return prov_err(json=prov_body, headers={"Content-Type": ContentType.APP_JSON}) + return prov_err(json=prov_body, content_type=ContentType.APP_JSON) links = job.links(container=request, self_link="provenance") headers = [("Link", make_link_header(link)) for link in links] - headers.append(("Content-Type", prov_type)) - return HTTPOk(body=prov_data, headers=headers) + return HTTPOk(body=prov_data, headers=headers, content_type=prov_type, charset="utf-8")