Skip to content

Commit 6ffa9dc

Browse files
fix: add constant
1 parent c800650 commit 6ffa9dc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/service-library/src/servicelib/aiohttp/rest_responses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from models_library.rest_error import ErrorGet, ErrorItemType
88

99
from ..aiohttp.status import HTTP_200_OK
10-
from ..mimetype_constants import MIMETYPE_APPLICATION_JSON
10+
from ..mimetype_constants import MIMETYPE_APPLICATION_JSON, MIMETYPE_TEXT_EVENT_STREAM
1111
from ..rest_constants import RESPONSE_MODEL_POLICY
1212
from ..rest_responses import is_enveloped
1313
from ..status_codes_utils import get_code_description, get_code_display_name, is_error
@@ -41,7 +41,7 @@ def create_event_stream_response(event_generator: Any) -> web.Response:
4141
body=event_generator(),
4242
status=HTTP_200_OK,
4343
reason=get_code_description(HTTP_200_OK),
44-
content_type="text/event-stream",
44+
content_type=MIMETYPE_TEXT_EVENT_STREAM,
4545
headers={"Cache-Control": "no-cache", "Connection": "keep-alive"},
4646
)
4747

packages/service-library/src/servicelib/mimetype_constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
88
SEE https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
99
"""
10+
1011
from typing import Final
1112

1213
# NOTE: mimetypes (https://docs.python.org/3/library/mimetypes.html) is already a module in python
1314

1415
MIMETYPE_APPLICATION_JSON: Final[str] = "application/json"
1516
MIMETYPE_APPLICATION_ND_JSON: Final[str] = "application/x-ndjson"
1617
MIMETYPE_APPLICATION_ZIP: Final[str] = "application/zip"
18+
MIMETYPE_TEXT_EVENT_STREAM: Final[str] = "text/event-stream"
1719
MIMETYPE_TEXT_HTML: Final[str] = "text/html"
1820
MIMETYPE_TEXT_PLAIN: Final[str] = "text/plain"

0 commit comments

Comments
 (0)