40 foreach ( headers_list() as
$header ) {
45 $headers[ strtolower( trim(
$header[0] ) ) ][] = trim(
$header[1] );
49 if ( isset( $headers[
'set-cookie'] ) ) {
50 $cacheControl = isset( $headers[
'cache-control'] )
51 ? implode(
', ', $headers[
'cache-control'] )
54 if ( !preg_match(
'/(?:^|,)\s*(?:private|no-cache|no-store)\s*(?:$|,)/i',
57 header(
'Expires: Thu, 01 Jan 1970 00:00:00 GMT' );
58 header(
'Cache-Control: private, max-age=0, s-maxage=0' );
59 \MediaWiki\Logger\LoggerFactory::getInstance(
'cache-cookies' )->warning(
60 'Cookies set on {url} with Cache-Control "{cache-control}"', [
61 'url' => \WebRequest::getGlobalRequestURL(),
62 'set-cookie' => self::sanitizeSetCookie( $headers[
'set-cookie'] ),
63 'cache-control' => $cacheControl ?:
'<not set>',
71 if ( !isset( $headers[
'x-request-id'] ) ) {
72 header(
'X-Request-Id: ' . \WebRequest::getRequestId() );
76 self::$headersSentException = new \Exception(
'Headers already sent from this point' );
104 $sanitizedValues = [];
105 foreach ( $values as $value ) {
107 $parts = explode(
';', $value );
108 list( $name, $value ) = explode(
'=', $parts[0], 2 );
109 if ( strlen( $value ) > 8 ) {
110 $value = substr( $value, 0, 8 ) .
'...';
111 $parts[0] =
"$name=$value";
113 $sanitizedValues[] = implode(
';', $parts );
115 return implode(
"\n", $sanitizedValues );