Skip to content

Conversation

ptpt
Copy link
Member

@ptpt ptpt commented Aug 19, 2025

This pull request refactors the API v4 authentication and HTTP request logic to streamline session management, improve code clarity, and make upload worker configuration more flexible. The main changes include replacing custom HTTP request handling with a shared http.Session, updating authentication flows to use session objects, and introducing a configurable number of upload workers.

API and HTTP session refactoring:

  • Removed custom HTTP request functions and SSL adapter logic from api_v4.py, replacing them with new create_user_session and create_client_session helpers that return pre-configured http.Session objects for authenticated requests. All API methods now accept a session object instead of raw tokens. [1] [2] [3] [4]
  • Moved request/response logging and header sanitization utilities to the new http module, updating all usages accordingly. [1] [2]

Authentication flow updates:

  • Updated authentication and user verification logic in authenticate.py to use the new session-based API, ensuring all requests are made through properly configured session objects. [1] [2] [3]

Upload worker configuration:

  • Added a new --num_upload_workers CLI argument to allow users to specify the number of concurrent upload workers, with a new default value.
  • Changed the default and maximum number of image upload workers from 64 to 4, and increased the upload chunk size from 1MB to 2MB for improved responsiveness.

These changes improve maintainability, security, and configurability of the upload and authentication processes.

@meta-cla meta-cla bot added the cla signed label Aug 19, 2025
@ptpt ptpt merged commit e6397eb into main Aug 19, 2025
16 checks passed
@ptpt ptpt deleted the improve-http-session branch August 19, 2025 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant