Skip to content

okhttp4 Phase E: consolidate GzipRequestInterceptor into one shared class - #4593

Open
ahaarrestad wants to merge 8 commits into
NightscoutFoundation:masterfrom
ahaarrestad:feat/okhttp4-phase-e-gzip-consolidation
Open

okhttp4 Phase E: consolidate GzipRequestInterceptor into one shared class#4593
ahaarrestad wants to merge 8 commits into
NightscoutFoundation:masterfrom
ahaarrestad:feat/okhttp4-phase-e-gzip-consolidation

Conversation

@ahaarrestad

Copy link
Copy Markdown
Contributor

Summary

Consolidates three separate GzipRequestInterceptor implementations into one shared class, with no observable behavior change. Part of the okhttp4 migration (Phase E — independent of the B1/B2 version bump in #4589; this branch is off master on okhttp 3.12.13).

What was actually there (the premise "3 identical copies" was wrong)

Copy Visibility Behavior Consumers
cgm/nsfollow/GzipRequestInterceptor public, // TODO make reusable gzip unless body == null or Content-Encoding present 4 cross-package consumers: SendFeedBack, NightLiteClient, RetrofitService, sharefollow/RetrofitBase
tidepool/GzipRequestInterceptor package-private byte-for-byte identical to nsfollow none — only usage was commented out → dead code
NightscoutUploader.GzipRequestInterceptor inner static class different — also gates on !supportsGzip(host+port) NightscoutUploader

So: 2 identical copies + 1 with a per-server capability gate — not 3 identical copies.

Change

  • New shared com.eveningoutpost.dexdrip.utils.framework.GzipRequestInterceptor + a small GzipDecider functional interface.
    • No-arg constructor → always gzip (byte-for-byte equal to the old nsfollow/tidepool behavior); used by the 4 nsfollow consumers.
    • GzipRequestInterceptor(GzipDecider) → per-request gate.
  • NightscoutUploader now passes NS_GZIP_DECIDER = req -> supportsGzip(host+port), preserving its per-server gzip gating verbatim (same id construction, same PersistentStore marker ns-end-supports-gzip-, same short-circuit order).
  • Migrated the 4 production consumers (+ 4 pre-existing test files) to the shared class.
  • Removed the dead tidepool/GzipRequestInterceptor copy and the dead commented-out usage line in TidepoolUploader.

Note: okhttp3.* / okio.* package names are correct and remain so under okhttp 4.x (4.x keeps the okhttp3 package). The deprecated RequestBody.create(MediaType, String) arg order is intentionally left for Phase C (deprecation cleanup); Phase E actually shrinks Phase C's gzip scope from 3 copies to 1.

Testing

  • New TDD characterization test pins NightscoutUploader's supportsGzip gate through the shared class (marker true → gzip; absent → passthrough; GET/no-body and already-encoded passthrough).
  • New shared-class test covers no-arg (gzip / no-body / already-encoded) + both decider outcomes — real MockWebServer round-trips, gunzip assertions.
  • Full ./gradlew testBUILD SUCCESSFUL, 0 failures.

ahaarrestad and others added 8 commits July 1, 2026 20:25
…(Phase E)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ase E)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…S_GZIP_DECIDER (Phase E)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tor (Phase E)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Delete the nsfollow and tidepool duplicate copies and their tests, now
that all consumers use the shared class at utils/framework. Also fix
four test files that still imported from the old nsfollow location, and
remove the dead commented-out addInterceptor line in TidepoolUploader.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…eptor (Phase E)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant