Skip to content

Commit 6be1498

Browse files
leak
1 parent ba048ef commit 6be1498

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

gateway-api/src/gateway_api/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ def text(self) -> str:
7575

7676
def create_mock_request(headers: dict[str, str], body: dict[str, Any]) -> Request:
7777
"""Create a proper Flask Request object with headers and JSON body."""
78+
content_type = headers.get("Content-Type", "application/fhir+json")
7879
builder = EnvironBuilder(
7980
method="POST",
8081
path="/patient/$gpc.getstructuredrecord",
8182
data=json.dumps(body),
82-
content_type="application/fhir+json",
83+
content_type=content_type,
8384
headers=headers,
8485
)
8586
env = builder.get_environ()

gateway-api/src/gateway_api/get_structured_record/request.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ def __init__(self, request: Request) -> None:
4747

4848
def _validate_content_type(self) -> None:
4949
content_type = self._headers.get("Content-Type")
50+
print(f"DEBUG content_type={content_type!r} headers={dict(self._headers)}")
5051
if content_type is None:
51-
return # if not provided, that's not invalid
52+
return
5253
if content_type.split(";")[0].strip().lower() != ACCEPTED_CONTENT_TYPE:
5354
raise UnsupportedMediaTypeError()
5455

gateway-api/src/gateway_api/get_structured_record/test_request.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def test_missing_content_type_header_is_accepted(
125125
) -> None:
126126
"""Test that a missing Content-Type header does not raise an error."""
127127
headers = {
128+
"Content-Type": "",
128129
"Ssp-TraceID": "test-trace-id",
129130
"ODS-from": "test-ods",
130131
}

0 commit comments

Comments
 (0)