René's URL Explorer Experiment


Title: Support caller-supplied `Content-Encoding` for pre-compressed request bodies · Issue #996 · apify/apify-client-python · GitHub

Open Graph Title: Support caller-supplied `Content-Encoding` for pre-compressed request bodies · Issue #996 · apify/apify-client-python

X Title: Support caller-supplied `Content-Encoding` for pre-compressed request bodies · Issue #996 · apify/apify-client-python

Description: Follow-up from a review comment on #987: #987 (comment) Problem There is no way for a caller to hand the client an already-encoded request body. Before #987, _prepare_request_call compressed every bytes-like body and merged its own Conte...

Open Graph Description: Follow-up from a review comment on #987: #987 (comment) Problem There is no way for a caller to hand the client an already-encoded request body. Before #987, _prepare_request_call compressed every ...

X Description: Follow-up from a review comment on #987: #987 (comment) Problem There is no way for a caller to hand the client an already-encoded request body. Before #987, _prepare_request_call compressed every ...

Opengraph URL: https://github.com/apify/apify-client-python/issues/996

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support caller-supplied `Content-Encoding` for pre-compressed request bodies","articleBody":"Follow-up from a review comment on #987: https://github.com/apify/apify-client-python/pull/987#discussion_r3704749196\n\n## Problem\n\nThere is no way for a caller to hand the client an already-encoded request body.\n\n- Before #987, `_prepare_request_call` compressed every bytes-like body and merged its own `Content-Encoding` last, so a caller-supplied value was silently overwritten.\n- Since #987, a caller-supplied `Content-Encoding` is dropped whenever compression is skipped, so a pre-compressed body goes out labeled as unencoded.\n\nThe API supports this and documents it. [`PUT key-value-store record`](https://docs.apify.com/api/v2/key-value-store-record-put) documents a `Content-Encoding` request header accepting `gzip`, `br`, `deflate`, and `identity`: \"To save bandwidth, storage, and speed up your upload, send the request payload compressed with Gzip compression and add the `Content-Encoding: gzip` header. It is possible to set up another compression type with `Content-Encoding` request header.\" And per the [key-value store docs](https://docs.apify.com/platform/storage/key-value-store), \"records are stored exactly as you upload them\", with the encoding taken from that header — so on that endpoint the header is record metadata, not just a transport hint, and dropping it stores compressed bytes under an unencoded label.\n\nHonoring the header also unlocks encodings the client ships no compressor for (`deflate`, `zstd`, ...) without having to add one.\n\n## How the JS client solves it\n\n`apify-client-js` treats a caller-supplied `content-encoding` as \"hands off\" — [`src/interceptors.ts#L81-L82`](https://github.com/apify/apify-client-js/blob/fd619c056e64743843ece519fe56ae87f0c1e687/src/interceptors.ts#L81-L82):\n\n```ts\nasync function maybeCompressRequest(config: ApifyRequestConfig): Promise\u003cApifyRequestConfig> {\n    if (config.headers?.['content-encoding']) return config;\n\n    const maybeCompressed = await maybeCompressValue(config.data);\n    ...\n}\n```\n\nNo opt-out parameter and no dedicated compressor — the header alone is the signal. (`maybeCompressValue` also skips bodies below `MIN_COMPRESS_BYTES = 1024`, which is #934 on the Python side.)\n\n## Proposal\n\n1. **Honor a caller-supplied `Content-Encoding` in `_prepare_request_call`**, matching JS. Precedence: caller `Content-Encoding` -> content-type heuristic (`is_compressible_content_type`) -> compress. The header is forwarded verbatim, so any encoding the backend accepts works, and `identity` becomes a per-request opt-out for free.\n\n    ```python\n    caller_encoding = next((v for k, v in headers.items() if k.lower() == 'content-encoding'), None)\n    if caller_encoding is None and is_compressible_content_type(content_type):\n        data = self._http_compressor.compress(data)\n        headers = self._merge_headers(headers, {'Content-Encoding': self._http_compressor.content_encoding})\n    ```\n\n    Explicitly out of scope: stacking the client's encoding on top of the caller's (`Content-Encoding: gzip, br`) — the backend does not document the list form.\n\n    This reverses the drop-the-header behavior added in #987 and flips `test_prepare_request_call_replaces_caller_content_encoding` plus the two `..._drops_caller_content_encoding_...` tests.\n\n2. **Expose `content_encoding` on `KeyValueStoreClient.set_record`** (sync and async). Step 1 on its own is barely reachable: no public resource method takes per-request headers, so the only entry points are the client-wide `ApifyClient(headers=...)`, which would apply the header to every request, and the private `_http_client.call`. `set_record` is where the API documents the header, so that is where it belongs.\n\nRejected: a per-request `compress=False` keyword on `HttpClient.call`. `HttpClient`/`HttpClientAsync` are a public ABC, and once resource clients pass the new keyword, existing custom implementations break. Headers already flow through, so step 1 covers the same need without touching that contract.\n\nDocs: add a pre-compressed bodies section to the HTTP compression concept page.\n\n*✍️ Drafted by Claude Code*\n","author":{"url":"https://github.com/vdusek","@type":"Person","name":"vdusek"},"datePublished":"2026-08-03T14:43:25Z","url":"https://github.com/apify/apify-client-python/issues/996"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ddc68c97-71e4-9512-3fa5-5831ffcfc0e7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAAB6:1DDD34:330B35:47FF12:6B005D4D
html-safe-nonce68bf13fa85bbbe592335d7a1164d51bd158d00d042e581bc2f61dcdd4552726b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUI2OjFEREQzNDozMzBCMzU6NDdGRjEyOjZCMDA1RDREIiwidmlzaXRvcl9pZCI6IjIwMDU5ODM1NTU2MzY3MTQ4MjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac778d398b904d50ec97fdcd5b6e268ab3e32d9085ab8bc0c667b14dec207d5eab
hovercard-subject-tagissue:5051035384
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/apify/apify-client-python/996/issue_layout
twitter:imagehttps://opengraph.githubassets.com/30136b19690c97d4920f2e731031c04135c6a2d9c537d4716abd87b80369ae06/apify/apify-client-python/issues/996
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/30136b19690c97d4920f2e731031c04135c6a2d9c537d4716abd87b80369ae06/apify/apify-client-python/issues/996
og:image:altFollow-up from a review comment on #987: #987 (comment) Problem There is no way for a caller to hand the client an already-encoded request body. Before #987, _prepare_request_call compressed every ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamevdusek
hostnamegithub.com
expected-hostnamegithub.com
None29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73
turbo-cache-controlno-preview
go-importgithub.com/apify/apify-client-python git https://github.com/apify/apify-client-python.git
octolytics-dimension-user_id24586296
octolytics-dimension-user_loginapify
octolytics-dimension-repository_id164647835
octolytics-dimension-repository_nwoapify/apify-client-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id164647835
octolytics-dimension-repository_network_root_nwoapify/apify-client-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseeacd927ba6112e3b01ba99c762bd699a4a4f5df7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/apify/apify-client-python/issues/996#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fapify%2Fapify-client-python%2Fissues%2F996
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fapify%2Fapify-client-python%2Fissues%2F996
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=apify%2Fapify-client-python
Reloadhttps://github.com/apify/apify-client-python/issues/996
Reloadhttps://github.com/apify/apify-client-python/issues/996
Reloadhttps://github.com/apify/apify-client-python/issues/996
apifyhttps://github.com/apify
apify-client-pythonhttps://github.com/apify/apify-client-python
Codehttps://github.com/apify/apify-client-python
Issues12 (12)https://github.com/apify/apify-client-python/issues
Pull requests2 (2)https://github.com/apify/apify-client-python/pulls
Discussionshttps://github.com/apify/apify-client-python/discussions
Actionshttps://github.com/apify/apify-client-python/actions
Security and qualityhttps://github.com/apify/apify-client-python/security
Insightshttps://github.com/apify/apify-client-python/insights
https://github.com/apify/apify-client-python
New issuehttps://github.com/login?return_to=https://github.com/apify/apify-client-python/issues/996
New issuehttps://github.com/login?return_to=https://github.com/apify/apify-client-python/issues/996
#997https://github.com/apify/apify-client-python/pull/997
Support caller-supplied Content-Encoding for pre-compressed request bodieshttps://github.com/apify/apify-client-python/issues/996#top
#997https://github.com/apify/apify-client-python/pull/997
https://github.com/vdusek
enhancementNew feature or request.https://github.com/apify/apify-client-python/issues?q=state%3Aopen%20label%3A%22enhancement%22
t-toolingIssues with this label are in the ownership of the tooling team.https://github.com/apify/apify-client-python/issues?q=state%3Aopen%20label%3A%22t-tooling%22
https://github.com/vdusek
vdusekhttps://github.com/vdusek
on Aug 3, 2026https://github.com/apify/apify-client-python/issues/996#issue-5051035384
#987https://github.com/apify/apify-client-python/pull/987
#987 (comment)https://github.com/apify/apify-client-python/pull/987#discussion_r3704749196
perf: Skip request-body compression for already-compressed content types #987https://github.com/apify/apify-client-python/pull/987
perf: Skip request-body compression for already-compressed content types #987https://github.com/apify/apify-client-python/pull/987
PUT key-value-store recordhttps://docs.apify.com/api/v2/key-value-store-record-put
key-value store docshttps://docs.apify.com/platform/storage/key-value-store
src/interceptors.ts#L81-L82https://github.com/apify/apify-client-js/blob/fd619c056e64743843ece519fe56ae87f0c1e687/src/interceptors.ts#L81-L82
#934https://github.com/apify/apify-client-python/issues/934
perf: Skip request-body compression for already-compressed content types #987https://github.com/apify/apify-client-python/pull/987
vdusekhttps://github.com/vdusek
enhancementNew feature or request.https://github.com/apify/apify-client-python/issues?q=state%3Aopen%20label%3A%22enhancement%22
t-toolingIssues with this label are in the ownership of the tooling team.https://github.com/apify/apify-client-python/issues?q=state%3Aopen%20label%3A%22t-tooling%22
on Aug 3, 2026https://github.com/apify/apify-client-python/issues/996#event-28894590730
vdusekhttps://github.com/vdusek
completedhttps://github.com/apify/apify-client-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#997https://github.com/apify/apify-client-python/pull/997
on Aug 4, 2026https://github.com/apify/apify-client-python/issues/996#event-28945792304
vdusekhttps://github.com/vdusek
on Oct 7, 2026https://github.com/apify/apify-client-python/issues/996#event-32685641614
Sign up for freehttps://github.com/signup?return_to=https://github.com/apify/apify-client-python/issues/996
Sign in to commenthttps://github.com/login?return_to=https://github.com/apify/apify-client-python/issues/996
vdusekhttps://github.com/vdusek
enhancementNew feature or request.https://github.com/apify/apify-client-python/issues?q=state%3Aopen%20label%3A%22enhancement%22
t-toolingIssues with this label are in the ownership of the tooling team.https://github.com/apify/apify-client-python/issues?q=state%3Aopen%20label%3A%22t-tooling%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.