Skip to content

aiohttp.ClientResponse.**mimetype** property #1349

Closed
@moden-py

Description

Long story short

It supposed to be a popular use case to get the content's mime type.
Even aiohttp uses the next construction several times(though not always for response):

ctype = self.headers.get(hdrs.CONTENT_TYPE, '').lower()
mtype, stype, _, params = helpers.parse_mimetype(ctype)

Lets add an easy way to get mime type?
aiohttp.helpers.parse_mimetype already done.

Expected behaviour

resp = await client_session.get(url)
async with resp:
    mtype, stype, suffix, params = resp.mimetype

PS

If agree I will make appropriate PR.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions