Skip to content

Make userAgent a true multi-stage routine#163

Merged
alganet merged 1 commit intoRespect:masterfrom
alganet:user-agent-routine
Mar 17, 2026
Merged

Make userAgent a true multi-stage routine#163
alganet merged 1 commit intoRespect:masterfrom
alganet:user-agent-routine

Conversation

@alganet
Copy link
Member

@alganet alganet commented Mar 17, 2026

Turn userAgent() into a routine that can participate in multiple phases of the request lifecycle instead of only post-processing responses.

Changes:

  • move negotiated callback storage/helpers into AbstractCallbackMediator so mediator-based routines can share state across stages
  • make UserAgent implement ProxyableBy as well as ProxyableThrough
  • allow userAgent callbacks to block before the route runs by returning false, a ResponseInterface, or a forwarded route
  • preserve response transformation behavior through userAgent callbacks after the route runs
  • avoid double-running zero-argument userAgent callbacks by preparing the through-stage result during by()
  • preserve through-only behavior for callbacks that require a response/input parameter and therefore cannot run safely before the route

Tests:

  • add router coverage for pre-route blocking via userAgent
  • add coverage for a single userAgent routine participating in both by and through stages
  • add coverage for transformer-style userAgent callbacks that remain post-route only
  • extend UserAgent routine tests for deny behavior and prepared through results

Verification:

  • composer qa

@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.30%. Comparing base (89994e6) to head (8f3768c).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #163      +/-   ##
============================================
+ Coverage     96.10%   96.30%   +0.19%     
- Complexity      418      433      +15     
============================================
  Files            27       27              
  Lines          1027     1055      +28     
============================================
+ Hits            987     1016      +29     
+ Misses           40       39       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Turn userAgent() into a routine that can participate in multiple phases of
the request lifecycle instead of only post-processing responses.

Changes:
- move negotiated callback storage/helpers into AbstractCallbackMediator so
  mediator-based routines can share state across stages
- make UserAgent implement ProxyableBy as well as ProxyableThrough
- allow userAgent callbacks to block before the route runs by returning
  false, a ResponseInterface, or a forwarded route
- preserve response transformation behavior through userAgent callbacks
  after the route runs
- avoid double-running zero-argument userAgent callbacks by preparing the
  through-stage result during by()
- preserve through-only behavior for callbacks that require a response/input
  parameter and therefore cannot run safely before the route

Tests:
- add router coverage for pre-route blocking via userAgent
- add coverage for a single userAgent routine participating in both by and
  through stages
- add coverage for transformer-style userAgent callbacks that remain
  post-route only
- extend UserAgent routine tests for deny behavior and prepared through
  results

Verification:
- composer qa
@alganet alganet force-pushed the user-agent-routine branch from 3d4ad09 to 8f3768c Compare March 17, 2026 21:56
@alganet alganet marked this pull request as ready for review March 17, 2026 21:56
@alganet alganet merged commit 7a9d34b into Respect:master Mar 17, 2026
3 checks passed
@alganet alganet deleted the user-agent-routine branch March 17, 2026 21:59
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