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

Function encode_response

httpx/_content.py:221–240  ·  httpx/_content.py::encode_response

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

(
    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 class="st">"""
228 Handles encoding the given `content`, returning a two-tuple of
229 (<headers>, <stream>).
230 class="st">"""
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(bclass="st">"")

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