discourse/spec/lib/middleware
Martin Brennan fb4bd7951a
FIX: Add request tracking headers to Message Bus responses (#35537)
Previously, we didn't pass through the `X-Discourse-Trackview` and
`X-Discourse-Browserpageview` headers in the MessageBus `/poll`
response.
This is because MessageBus has a specific way of defining extra headers,
which we do in the `004-message_bus.rb` initializer.

We were adding the `X-Discourse-*` headers in `RequestTracker` after
`@app.call` was called, so the MessageBus middleware which is lower in
the
middleware stack would not have access to this data.

So in this commit, we hoist this data collection about the request
tracking above the `@app.call` line so it's acceessible in the
MessageBus middleware and we can add them to the response there. We
also move this data collection into a reusable method so we can call it
from before the env and also later when actually logging the request.

Followup 33abb858e9
2025-10-27 12:21:37 +10:00
..
anonymous_cache_spec.rb FIX: Update 'modern mobile' regex following iOS 15 support drop (#34792) 2025-09-12 11:33:30 -04:00
crawler_hooks_spec.rb DEV: Check for setting prior to applying transformation on crawler view (#34478) 2025-08-22 14:17:45 +08:00
discourse_public_exceptions_spec.rb DEV: Don’t replace Rails logger in specs (#29721) 2024-11-13 08:47:39 +08:00
enforce_hostname_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
request_tracker_spec.rb FIX: Add request tracking headers to Message Bus responses (#35537) 2025-10-27 12:21:37 +10:00