Set X-Request-Id on all web responses
To make correlating MediaWiki logs and reverse proxy logs easier,
set the X-Request-Id header on responses. Ideally the header
would be set by the reverse proxy on the incoming request (see
e.g. T221976), but that is more complicated to set up consistently
and will be different for different MediaWiki setups; this patch
provides a simple fallback mechanism.
When the request itself had an X-Request-Id header (and
$wgAllowExternalReqID is set), this makes MediaWiki reflect that
header back; otherwise the value is a long random string.
Given that the header will be cached by reverse proxies, it is
not really a request ID (something unique to the request
that the header was sent in response to) as a "request group ID"
(shared by all requests which were served with the same cached
response), but we already had this semantic mismatch with the
wgRequestId JS variable, this patch just makes the ID easier
to log.
Bug: T201409
Change-Id: I9bca677b945ca3aa0e50d81bb468862efec54890