Results¶
FetchResult(fn)
¶
Bases: LazyExecutionChain[..., Response]
Execution chain producing an HTTP response.
Wraps a deferred HTTP request and exposes helpers for consuming the response body as a stream, an in-memory buffer, or an extracted archive.
The response lifecycle is managed explicitly. The response is closed deterministically once consumption completes or aborts.
init(url, *, params=None, headers=None, cookies=None, auth=None, follow_redirects=True, timeout=None)
¶
Initializes the underlying HTTP request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Target URL. |
required |
params
|
Mapping[str, Any] | None
|
Optional query parameters. |
None
|
headers
|
Mapping[str, str] | None
|
Optional request headers. |
None
|
cookies
|
Dict[str, str] | None
|
Optional cookies mapping. |
None
|
auth
|
Auth | None
|
Optional authentication handler. |
None
|
follow_redirects
|
bool
|
Whether redirects are followed automatically. |
True
|
timeout
|
float | None
|
Optional request timeout. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The current fetch result instance. |
content_stream(*, max_content_length=None, chunk_size=None)
async
¶
Consumes the response body as a streamed content generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_content_length
|
int | None
|
Optional upper bound for total content size. |
None
|
chunk_size
|
int | None
|
Optional chunk size for streaming. |
None
|
Returns:
| Type | Description |
|---|---|
ContentStream
|
Stream of content chunks. |
buffer(*, max_content_length=None, chunk_size=None)
async
¶
Consumes the response body into an in-memory buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_content_length
|
int | None
|
Optional upper bound for total content size. |
None
|
chunk_size
|
int | None
|
Optional chunk size for reading. |
None
|
Returns:
| Type | Description |
|---|---|
IO[bytes]
|
In-memory buffer containing the response body. |
extract(content_types=None, *, max_content_length=None, chunk_size=None, max_file_size=None, max_compression_ratio=None)
¶
Extracts archive contents from the response body.
The response body is fully buffered before extraction. Files are processed sequentially and yielded as a content stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content_types
|
Sequence[str] | None
|
Optional allowed content types for extracted files. |
None
|
max_content_length
|
int | None
|
Optional upper bound for response size. |
None
|
chunk_size
|
int | None
|
Optional chunk size for reading and extraction. |
None
|
max_file_size
|
int | None
|
Optional upper bound for extracted file size. |
None
|
max_compression_ratio
|
float | None
|
Optional compression ratio limit. |
None
|
Returns:
| Type | Description |
|---|---|
ExtractResult
|
Extraction result producing extracted content. |
save(base_path=None, *, max_content_length=None, chunk_size=None)
¶
Persists the response body directly to the filesystem.
The response body is streamed and written incrementally. The response is closed once streaming completes or aborts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
str | Path | None
|
Target directory for saved files. Defaults to the current working directory. |
None
|
max_content_length
|
int | None
|
Optional upper bound for total content size. |
None
|
chunk_size
|
int | None
|
Optional chunk size for streaming. |
None
|
Returns:
| Type | Description |
|---|---|
LazyExecutionNode[[ContentStream], None]
|
Execution node performing the save operation. |
ExtractResult(fn)
¶
Bases: LazyExecutionChain[..., ContentStream]
Execution chain producing a streamed extraction result.
Represents a deferred extraction step that yields a content stream. Instances are typically attached to a preceding execution step that produces a binary input suitable for extraction.
save(base_path=None)
¶
Persists extracted content to the filesystem.
The returned execution node consumes a content stream and writes all yielded chunks under the provided base path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
str | Path | None
|
Target directory for extracted files. Defaults to the current working directory. |
None
|
Returns:
| Type | Description |
|---|---|
LazyExecutionNode[[ContentStream], None]
|
Execution node performing the save operation. |