Repository navigation
refactor!: Remove automatic X-Powered-By header - #169
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughRemoves support for configuring or auto-injecting the X-Powered-By header. Updates RelicServer and serve API to drop the poweredByHeader parameter and related constants/fields. Middleware now only ensures a Date header. Tests are updated to reflect absence of automatic X-Powered-By and to use per-response headers when needed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant S as RelicServer
participant H as Handler
C->>S: HTTP Request
S->>H: Invoke handler
H-->>S: Response (may include headers)
rect rgba(200,230,255,0.3)
note over S: Header normalization
S->>S: Ensure Date header if missing
note over S: No X-Powered-By injection
end
S-->>C: HTTP Response
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
01564b5 to
0077109
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #169 +/- ##
==========================================
- Coverage 91.77% 91.76% -0.01%
==========================================
Files 85 85
Lines 3123 3122 -1
Branches 1618 1618
==========================================
- Hits 2866 2865 -1
Misses 257 257 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
lib/src/relic_server.dart (1)
116-123: Use UTC for Date header generation.HTTP Date must be IMF-fixdate in GMT. Prefer UTC to avoid ambiguity and accidental local‑time emission.
Apply:
- mh.date ??= DateTime.now(); + mh.date ??= DateTime.now().toUtc();test/relic_server_serve_test.dart (1)
372-381: Deduplicate with first test.This repeats “not automatically set” through a different setup path. Consider merging to reduce flakiness/time.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
lib/src/adapter/io/io_serve.dart(1 hunks)lib/src/relic_server.dart(1 hunks)test/headers/basic/x_powered_by_header_test.dart(1 hunks)test/relic_server_serve_test.dart(2 hunks)test/util/test_util.dart(0 hunks)
💤 Files with no reviewable changes (1)
- test/util/test_util.dart
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-23T04:15:01.420Z
Learnt from: nielsenko
PR: serverpod/relic#76
File: lib/src/handler/handler.dart:20-20
Timestamp: 2025-05-23T04:15:01.420Z
Learning: In the relic codebase, ResponseContext is a subtype of HandledContext, making functions with signature ResponseContext Function(RequestContext) assignable to the Handler typedef (FutureOr<HandledContext> Function(NewContext ctx)) due to covariant return types and contravariant parameter types in Dart's type system.
Applied to files:
lib/src/relic_server.dart
🔇 Additional comments (6)
test/headers/basic/x_powered_by_header_test.dart (3)
9-16: LGTM: accessor-based validation is clear.Good pivot away from server defaults; this verifies explicit, opt‑in behavior.
22-31: LGTM: null handling covered.Confirms header omission semantics when unset.
33-42: LGTM: response preserves explicitly set header.Covers end-to-end preservation via Response.ok.
test/relic_server_serve_test.dart (3)
350-357: LGTM: no automatic X-Powered-By.Asserts the new default (absent) correctly.
360-367: LGTM: manual per-response header works.Verifies explicit opt‑in.
383-391: LGTM: preserves manually set header.Covers server created via testServe path.
0077109 to
4a9ee71
Compare
SandPod
left a comment
There was a problem hiding this comment.
LGTM! One question regarding a test.
4a9ee71 to
e24b46b
Compare
BREAKING CHANGE: The serve() function no longer accepts a poweredByHeader parameter and Relic no longer automatically sets the X-Powered-By header on responses. Users who want this header can set it manually using middleware or by setting it directly on Response objects. Fixes serverpod#165
e24b46b to
c3ebe45
Compare
Description
The
serve()function no longer accepts apoweredByHeaderparameter and Relic no longer automatically sets the X-Powered-By header on responses.Users who want this header can set it manually using middleware or by setting it directly on Response objects.
Related Issues
Pre-Launch Checklist
Please ensure that your PR meets the following requirements before submitting:
///), ensuring consistency with existing project documentation.Breaking Changes
The
serve()function no longer accepts apoweredByHeaderparameterSummary by CodeRabbit