mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-11-21 20:00:49 +01:00
Each Subsonic or Mornye Link metadata read (getSong, then the cover and lyrics in parallel) built a new HttpClient and force closed it, so every song start paid one or two fresh TLS handshakes while streaming already used a pooled client. NetworkMetadataService now keeps one SubsonicClient per connection id and reuses its keep-alive connections across reads. The client is reused only for the exact saved connection (its JSON, so address, credentials, API key and certificate pin), so an edit opens a new client and retires the old one once its last read ends. It also closes after 20 s without reads, when the connection is removed, on cancelPending, and after a transport failure (anything but a Subsonic error, an HTTP status or a local cache file error). Requests, headers, timeouts, certificate pinning and redirect rules are unchanged, since every request still goes through NetworkStorageService._request. Measured on a local HTTPS fixture with a pinned self-signed certificate, six metadata reads in a row: 6 HttpClients and 7 TLS connections before, 1 HttpClient and 2 TLS connections after, same 13 requests.