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