mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-20 22:41:38 +02:00
client.rs held the connection pool, the streaming response type, header helpers, tests and a 274-line execute_stream in one 1220-line file (audit RS-15). Move the self-contained parts into client/ and break execute_stream into phase helpers so the redirect loop reads top-down. Pure moves (verbatim apart from pub(super) on items the parent uses): - client/pool.rs: Connector and Pool. - client/stream.rs: ResponseBody and HttpStream (re-exported from client, so crate::HttpStream is unchanged). - client/headers.rs: update_explicit_cookies, forward_sensitive_headers and canonical_header. error_chain stays in client.rs; it is not a header helper. - client/tests.rs: the existing unit tests. execute_stream helpers (base line ranges refer to main:client.rs). Each body is the statements it replaces; the loop, await points, error mapping, redirect limit and header mutations stay in the same order: - prepare_request: 720-769, request validation, method, body, headers, user agent, default JSON content type and explicit referer, returned as PreparedRequest. Only the mut markers moved to the call site. - outgoing_headers: 773-802, per-attempt cookie header and gzip negotiation, returning (outgoing, gzip). header(&url) became header(url) because url is now a reference. - send: 803-845, the request, its 45 s header timeout and the native HTTPS-to-HTTP fallback retry. The permit is passed by value and returned, so drop(permit) still runs before the retry acquires a new one. matches!(method, ..) became matches!(*method, ..). - redirect_target: 862-869, Location resolution, credential rejection and redirect policy validation, returning the target. - release_redirect_body: 906-928, the 20 ms drain of a small HTTP/1.1 redirect body. - response_reader: 932-959, discard eligibility and gzip decoder setup, returning (headers, small_http1, reader). - canonical_headers: 960-970, canonical response header map. The redirect request rewrite (871-905) stays inline: it updates the loop-carried method, body and headers and reads six other values, so a helper would need nine parameters or a state struct that rewrites every statement in the loop. hyper is not a direct dependency, so the response type is named through the pooled client's tower Service implementation (HyperResponse). No public path or signature changes.