Repository navigation
[PR #13299/5fa85842 backport][3.14] Avoid generating an unused Date header fallback - #13544
Conversation
Co-authored-by: J. Nick Koston <nick@koston.org> (cherry picked from commit 5fa8584)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.14 #13544 +/- ##
==========================================
- Coverage 96.22% 96.21% -0.02%
==========================================
Files 160 160
Lines 51079 51133 +54
Branches 2761 2778 +17
==========================================
+ Hits 49151 49196 +45
- Misses 1751 1756 +5
- Partials 177 181 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Co-authored-by: Sam Bull <aa6bs0@sambull.org>
Merging this PR will degrade performance by 14.74%
|

This is a backport of PR #13299 as merged into master (5fa8584).
What do these changes do?
headers.setdefault(hdrs.DATE, rfc822_formatted_time())evaluates the formatter even when the response already has aDateheader, so the clock read (and possible cache refresh) happens and the result is discarded. This switches to a presence check so the formatter only runs when its value is used, and adds a regression test plus a small_prepare_headers()benchmark with and without an explicitDate.Locally, a paired A/B run showed ~0.45 µs (~2.4%) per response on the explicit-
Datepath and no measurable change on the generated-Datepath.Follow-up to #9898: that benchmark only constructed
Responseobjects and never reached_prepare_headers(), which is why CodSpeed showed no change.Are there changes in behavior for the user?
No. A user-supplied
Dateis still retained.Is it a substantial burden for the maintainers to support this?
No.
Related issue number
N/A (see #9898 above)
Checklist
required for this internal performance cleanup)
CONTRIBUTORS.txtCHANGES/folderAI assistance
Drafted with help from GPT-5.6 Sol (benchmarking, parts of this description); code by me. I've reviewed all of the code and remain responsible for the submission.