Releases: diprog/python-tls-client-async
2.0.0
Version 2.0.0 - Enhanced Cookie Handling and Stability Improvements
This major release fundamentally changes how cookies are managed and addresses several critical issues with redirect handling and session persistence. The TLS client now handles cookies natively through the shared library rather than Python-side implementations.
Major Changes
🍪 Cookie Handling Improvements
- Native cookie management through shared library fixes redirect cookie persistence (#120)
- Added
session.get_cookies()
andsession.add_cookies()
methods - Automatic domain/path validation using standard library rules
- Full support for secure/httpOnly flags and expiration
- Cookies now persist correctly through redirect chains
⚠ Breaking Changes
- Dropped
requests
dependency and related structures session.cookies
is now read-only (CookieJar interface)CaseInsensitiveDict
replaced withnocasedict
implementation
🛠 Known Limitations
- Manual cookie modification via
session.cookies
is not supported (issues #25, #73) - Cookie deletion/clearing methods are not yet implemented in the shared library
- Session cookies should be managed through
add_cookies()
/get_cookies()
methods
🚀 Other Improvements
- Added proper type hints and request options typing
Upgrade Instructions
-
Replace any
session.cookies
manipulation with explicit cookie methods:# Get cookies for domain cookies = await session.get_cookies("https://example.com") # Add new cookies await session.add_cookies([ {"name": "test", "value": "123", "domain": "example.com"} ], "https://example.com")
-
Remove any
requests
-specific code from your implementation
1.2
Release 1.2 - "We Copied Requests So You Don't Have To" 😴
I'm too sleepy to write proper release notes, but here’s the gist:
-
We stopped reinventing the wheel 🛞
Instead of copyingrequests
internals (likeCaseInsensitiveDict
), we now just use them directly. Less code, fewer bugs, moreimport requests
. Though slightly changedRequestsCookieJar
class is still present incookies.py
... -
Tests exist now! 🎯
Turns out, writing tests before midnight is a good idea. Who knew?
Breaking Changes?
Only if you were digging into our internal structures (which you shouldn’t have been doing anyway).
Why Upgrade?
- Fewer bugs 🐛
- More sleep for the maintainer 😴 (me)
1.1.1
This release introduces significant improvements in packaging, dependency management, and code organization while maintaining backward compatibility with the original tls-client
implementation.
📦 Packaging Modernization
- ✅ Migrated to modern
pyproject.toml
-based packaging (PEP 621 compliant) - 🧹 Removed legacy files:
setup.py
,__version__.py
,requirements.txt
- 🛠️ Enhanced build process with setuptools>=65.0 and wheel
- 📁 Improved package data handling with explicit binary file inclusion
🔄 Dynamic Library Updates
- 🔄 New dynamic shared library fetcher that automatically:
- 📡 Fetches latest 1.x releases from bogdanfinn/tls-client
- 🗃️ Renames binaries consistently across platforms
- 🔄 Keeps dependencies up-to-date without manual intervention
🧱 Code Improvements
- 📁 Restructured session module:
- Moved to
session/async_session.py
for better organization - Added proper module initialization
- Moved to
- 🛠️ Fixed critical typo in exception class name:
TLSClientExeption
→TLSClientException
- 🧼 Cleaned up imports and type hints
- 🔄 Renamed
settings.py
→types.py
for clarity
1.1
This release introduces a critical fix for handling binary responses, such as images or PDFs, ensuring they are properly decoded and accessible through response.content
and response.text
.
🔧 Summary of Changes
The Go-based TLS client now always returns byte-level responses (when isByteResponse=true
) in base64 format with MIME type prefixes like:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASw...
This allows the Python wrapper to:
- Safely decode base64 data
- Preserve binary content integrity
- Avoid UTF-8 decoding errors
The Python side was updated to:
- Handle malformed or missing base64 prefixes gracefully
- Decode response bodies safely
📦 What’s Fixed
1. Binary Response Corruption
Previously, binary data was treated as UTF-8 text, leading to corruption or exceptions when trying to read files like images.
Now, thanks to the Go-side change and updated Python logic:
response = await session.get("https://example.com/image.png")
with open("image.png", "wb") as f:
f.write(response.content) # This now works reliably
2. Text Decoding Improvements
Used errors='replace'
instead of 'ignore'
to avoid silent data loss:
response.text = decoded.decode(errors='replace')
💡 Technical Highlights
Component | Change |
---|---|
Python (response.py ) |
Safely decodes base64 responses and handles malformed ones |
Python (sessions.py ) |
Sets "isByteResponse": True by default |
🐛 Related Issues
This release resolves several long-standing issues related to binary responses:
- FlorianREGAZ/Python-Tls-Client#83
- FlorianREGAZ/Python-Tls-Client#119
- FlorianREGAZ/Python-Tls-Client#117
- FlorianREGAZ/Python-Tls-Client#83
🚀 Installation
pip install -U async_tls_client