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

Function stream

httpx/_api.py:124–171  ·  view source on GitHub ↗

Alternative to `httpx.request()` that streams the response body instead of loading it into memory at once. **Parameters**: See `httpx.request`. See also: [Streaming Responses][0] [0]: /quickstart#streaming-responses

(
    method: str,
    url: URL | str,
    *,
    params: QueryParamTypes | None = None,
    content: RequestContent | None = None,
    data: RequestData | None = None,
    files: RequestFiles | None = None,
    json: typing.Any | None = None,
    headers: HeaderTypes | None = None,
    cookies: CookieTypes | None = None,
    auth: AuthTypes | None = None,
    proxy: ProxyTypes | None = None,
    timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
    follow_redirects: bool = False,
    verify: ssl.SSLContext | str | bool = True,
    trust_env: bool = True,
)

Source from the content-addressed store, hash-verified

122
123@contextmanager
124def stream(
125 method: str,
126 url: URL | str,
127 *,
128 params: QueryParamTypes | None = None,
129 content: RequestContent | None = None,
130 data: RequestData | None = None,
131 files: RequestFiles | None = None,
132 json: typing.Any | None = None,
133 headers: HeaderTypes | None = None,
134 cookies: CookieTypes | None = None,
135 auth: AuthTypes | None = None,
136 proxy: ProxyTypes | None = None,
137 timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
138 follow_redirects: bool = False,
139 verify: ssl.SSLContext | str | bool = True,
140 trust_env: bool = True,
141) -> typing.Iterator[Response]:
142 """
143 Alternative to `httpx.request()` that streams the response body
144 instead of loading it into memory at once.
145
146 **Parameters**: See `httpx.request`.
147
148 See also: [Streaming Responses][0]
149
150 [0]: /quickstart#streaming-responses
151 """
152 with Client(
153 cookies=cookies,
154 proxy=proxy,
155 verify=verify,
156 timeout=timeout,
157 trust_env=trust_env,
158 ) as client:
159 with client.stream(
160 method=method,
161 url=url,
162 content=content,
163 data=data,
164 files=files,
165 json=json,
166 params=params,
167 headers=headers,
168 auth=auth,
169 follow_redirects=follow_redirects,
170 ) as response:
171 yield response
172
173
174def get(

Callers

nothing calls this directly

Calls 2

ClientClass · 0.85
streamMethod · 0.45

Tested by

no test coverage detected