Use content type multipart constant (#40314)

This commit is contained in:
springstan 2020-09-23 11:29:56 +02:00 committed by GitHub
parent 7876cdb37a
commit c2d20c548f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -35,6 +35,7 @@ from homeassistant.components.stream.const import (
from homeassistant.const import (
ATTR_ENTITY_ID,
CONF_FILENAME,
CONTENT_TYPE_MULTIPART,
EVENT_HOMEASSISTANT_START,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
@ -184,7 +185,7 @@ async def async_get_still_stream(request, image_cb, content_type, interval):
This method must be run in the event loop.
"""
response = web.StreamResponse()
response.content_type = "multipart/x-mixed-replace; boundary=--frameboundary"
response.content_type = CONTENT_TYPE_MULTIPART.format("--frameboundary")
await response.prepare(request)
async def write_to_mjpeg_stream(img_bytes):

View File

@ -7,6 +7,7 @@ import voluptuous as vol
from homeassistant.const import (
ATTR_ENTITY_ID,
CONTENT_TYPE_MULTIPART,
EVENT_HOMEASSISTANT_START,
EVENT_HOMEASSISTANT_STOP,
)
@ -122,9 +123,9 @@ class FFmpegManager:
def ffmpeg_stream_content_type(self):
"""Return HTTP content type for ffmpeg stream."""
if self._major_version is not None and self._major_version > 3:
return "multipart/x-mixed-replace;boundary=ffmpeg"
return CONTENT_TYPE_MULTIPART.format("ffmpeg")
return "multipart/x-mixed-replace;boundary=ffserver"
return CONTENT_TYPE_MULTIPART.format("ffserver")
class FFmpegBase(Entity):