Skip to content

fix: use shared Response object when running inside framework#98

Merged
usernane merged 1 commit intomainfrom
dev
Apr 28, 2026
Merged

fix: use shared Response object when running inside framework#98
usernane merged 1 commit intomainfrom
dev

Conversation

@usernane
Copy link
Copy Markdown
Member

Summary

When WebServicesManager is used within the WebFiori framework, it now uses App::getResponse() instead of creating its own Response instance. This ensures middleware-added headers (e.g. Set-Cookie from StartSessionMiddleware) are included in API responses.

Motivation

Middleware headers were lost because the API manager and the framework used separate Response objects. Session cookies set by start-session middleware never reached the client on API routes. Fixes #97.

Changes

  • Modified WebServicesManager::__construct() to check if App::getResponse() is available and use it as the shared response object
  • Falls back to new Response() for standalone usage outside the framework

How to Test / Verify

  1. Create an API service with session-based auth
  2. Assign start-session middleware to the route
  3. Call the login endpoint
  4. Verify Set-Cookie header is present in the response

Breaking Changes and Migration Steps

None. Standalone usage of the HTTP library is unaffected — it falls back to creating its own Response when the framework is not present.

Checklist

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • The title of the pull request follows Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed)
  • I ran lint/cs-fixer (if applicable)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #97

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

❌ Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.12%. Comparing base (baea2d5) to head (34ce8e8).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
WebFiori/Http/WebServicesManager.php 25.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #98      +/-   ##
============================================
- Coverage     92.30%   92.12%   -0.18%     
- Complexity     1265     1268       +3     
============================================
  Files            39       39              
  Lines          3042     3049       +7     
============================================
+ Hits           2808     2809       +1     
- Misses          234      240       +6     
Flag Coverage Δ
php-8.1 91.89% <25.00%> (-0.20%) ⬇️
php-8.2 91.96% <25.00%> (-0.18%) ⬇️
php-8.3 91.96% <25.00%> (-0.18%) ⬇️
php-8.4 91.96% <25.00%> (-0.18%) ⬇️
php-8.5 91.96% <25.00%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@sonarqubecloud
Copy link
Copy Markdown

@usernane usernane merged commit e4f687d into main Apr 28, 2026
17 of 19 checks passed
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.

bug: WebServicesManager creates its own Response, ignoring middleware headers

1 participant