Skip to content

Ambiguous error when getting 401 from server #33

Description

@vhaldemar

Hey!
I'm trying to use a sse backend which could return 401 Unathorized with "application/json" in headers and getting very ambiguous exception without any leads.

  File "...", line 120, in _run_stream
    async for sse in event_source.aiter_sse():
  File ".../lib/python3.12/site-packages/httpx_sse/_api.py", line 39, in aiter_sse
    self._check_content_type()
  File ".../lib/python3.12/site-packages/httpx_sse/_api.py", line 19, in _check_content_type
    raise SSEError(
httpx_sse._exceptions.SSEError: Expected response header Content-Type to contain 'text/event-stream', got 'application/json'

I'm not sure how usual it for see backends and how to properly fix it;
response.raise_for_status() in EventStream constructor will probably do the trick

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions