MCPcopy
hub / github.com/encode/httpx / encode_response

Function encode_response

httpx/_content.py:221–240  ·  view source on GitHub ↗

Handles encoding the given `content`, returning a two-tuple of ( , ).

(
    content: ResponseContent | None = None,
    text: str | None = None,
    html: str | None = None,
    json: Any | None = None,
)

Source from the content-addressed store, hash-verified

219
220
221def encode_response(
222 content: ResponseContent | None = None,
223 text: str | None = None,
224 html: str | None = None,
225 json: Any | None = None,
226) -> tuple[dict[str, str], SyncByteStream | AsyncByteStream]:
227 """
228 Handles encoding the given `content`, returning a two-tuple of
229 (<headers>, <stream>).
230 """
231 if content is not None:
232 return encode_content(content)
233 elif text is not None:
234 return encode_text(text)
235 elif html is not None:
236 return encode_html(html)
237 elif json is not None:
238 return encode_json(json)
239
240 return {}, ByteStream(b"")

Callers 1

__init__Method · 0.85

Calls 5

encode_contentFunction · 0.85
encode_textFunction · 0.85
encode_htmlFunction · 0.85
encode_jsonFunction · 0.85
ByteStreamClass · 0.85

Tested by

no test coverage detected