Skip to content

Replace requests with http client - #465

Closed
Sab44 wants to merge 4 commits into
jellyfin:masterfrom
Sab44:replace-requests-with-http-client
Closed

Sab44 wants to merge 4 commits into
jellyfin:masterfrom
Sab44:replace-requests-with-http-client

Conversation

@Sab44

@Sab44 Sab44 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

This is the most significant improvement found during my work to improve load times for JellyCon widgets.

This PR drops the requests dependency and uses a small lightweight http_client based on the Python standard library instead.

The new http_client module covers what the API client needs on top of http.client: timeouts, certificate checking (with certifi when available), redirects and gzip/deflate bodies. Everything should work the exact same way as before, the only difference is that now we send a custom user-agent header (JellyCon/<version>) instead of the default one that requests sends (python-requests/x).

On my ODroid N2+ I measured ~0.33 s to import requests which affects every plugin call. When loading 4 widgets on a home screen, the total load time improvement was a very significant ~6.1 s.

The changes here were done with AI assistance (Claude Opus 5.5). I reviewed everything and verified changes manually.

I am aware this is not a small change. If desired, I can provide detailed information about my testing (logs with timestamps, the specific widgets I used, my JellyCon settings etc.). Let me know and I'll be happy to help where I can, would love to see this merged so others can benefit and I don't have to maintain my own fork.

Sab44 added 4 commits November 4, 2026 10:18
…dency

script.module.certifi becomes a direct dependency: requests used to bring
it along, and http_client uses its CA bundle for certificate checks.
A 204 or other empty response can still carry a Content-Encoding
header, and zlib fails on empty input.
requests sent its own User-Agent, http.client sends none, which some
reverse proxies and firewalls reject.
@mcarlton00

Copy link
Copy Markdown
Member

I genuinely have no interest in this, sorry. We explicitly moved to requests over the built in httplib for ease of maintainability way back in #7. A small speed increase on what's effectively 6 year old potato hardware isn't worth undoing that, imo.

Current master loads my home in 3.52 seconds. This PR loads it in 3.47 seconds. That's such a small difference it might as well not exist. Might be a better use of time to make more varied custom widgets that have less in scope so they load faster (ie: it's significantly faster to load Movies - Random (20) than All Movies pulling all 1500 movies from my server)

@mcarlton00 mcarlton00 closed this Nov 11, 2026
@Sab44

Sab44 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the thorough response, I understand. Indeed, with the context of the previous PR that introduced requests this change seems uncalled for.

what's effectively 6 year old potato hardware

Fair point 😄 nevertheless, it does the job just fine. If it wasn't for that slow widget loading. I already made sure my widgets are limited to request only 20 items, that did improve things a bit as well. But you're right, eventually a more powerful device will have to come in.

@Sab44
Sab44 deleted the replace-requests-with-http-client branch November 11, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants