84 $this->mCacheDuration =
null;
86 $this->mConfig = $config ?: MediaWikiServices::getInstance()->getMainConfig();
88 $this->mDisabled =
false;
90 $this->mResponseCode = 200;
91 $this->mLastModified =
false;
92 $this->mContentType =
'application/x-wiki';
104 $this->mResponseCode = $code;
112 $this->mContentType =
$type;
119 $this->mDisabled =
true;
127 if ( !$this->mDisabled && $text ) {
128 $this->mText .= $text;
136 if ( !$this->mDisabled ) {
145 if ( $this->mResponseCode ) {
150 $n = intval( trim( $this->mResponseCode ) );
151 HttpStatus::header( $n );
154 header(
"Content-Type: " . $this->mContentType );
156 if ( $this->mLastModified ) {
157 header(
"Last-Modified: " . $this->mLastModified );
159 header(
"Last-Modified: " . gmdate(
"D, d M Y H:i:s" ) .
" GMT" );
162 if ( $this->mCacheDuration ) {
163 # If CDN caches are configured, tell them to cache the response,
164 # and tell the client to always check with the CDN. Otherwise,
165 # tell the client to use a cached copy, without a way to purge it.
166 if ( $this->mConfig->get(
'UseCdn' ) ) {
167 # Expect explicit purge of the proxy cache, but require end user agents
168 # to revalidate against the proxy on each visit.
169 header(
'Cache-Control: s-maxage=' . $this->mCacheDuration .
', must-revalidate, max-age=0' );
171 # Let the client do the caching. Cache is not purged.
172 header(
"Expires: " . gmdate(
"D, d M Y H:i:s", time() + $this->mCacheDuration ) .
" GMT" );
173 header(
"Cache-Control: s-maxage={$this->mCacheDuration}," .
174 "public,max-age={$this->mCacheDuration}" );
178 # always expired, always modified
179 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
180 header(
"Cache-Control: no-cache, must-revalidate" );
181 header(
"Pragma: no-cache" );
184 if ( $this->mVary ) {
185 header(
"Vary: " . $this->mVary );
Handle responses for Ajax requests (send headers, print content, that sort of thing)
sendHeaders()
Construct the header and output it.
string $mContentType
HTTP header Content-Type.
string $mVary
HTTP Vary header.
string bool $mLastModified
Date for the HTTP header Last-modified.
setResponseCode( $code)
Set the HTTP response code.
addText( $text)
Add content to the response.
int string $mResponseCode
HTTP response code.
__construct( $text=null, Config $config=null)
bool $mDisabled
Disables output.
string $mText
Content of our HTTP response.
setContentType( $type)
Set the HTTP header Content-Type.
int $mCacheDuration
Number of seconds to get the response cached by a proxy.
while(( $__line=Maintenance::readconsole()) !==false) print
Interface for configuration instances.