Not a developer? Go to MovableType.com

Documentation

Working with HTTP Headers

The following methods allow the plugin developer to modify the HTTP headers that are returned with a request.

$app->get_header($str)

This method returns the value of the HTTP header passed in as input.

$app->response_code($int)

This method sets the HTTP status code that will be sent with the response. Most of the time this is done for you by Movable Type, but from time to time, you may wish to override the default. Here are the most common response codes:

  • “200” - success
  • “301” - page has moved (a.k.a. “redirect”)
  • “404” - page not found
  • “500” - yikes, an error occurred

See also: List of HTTP codes

$app->response_content_type($str)

This methods sets the content type of the response returned by Movable Type. In almost all circumstances this is “text/html,” but developers from time to time may wish to override this default setting.

$app->response_message($str)

This method sets the message that is returned in conjunction with any request that is not a success (or an HTTP status code of 200). This message is displayed in most browsers and can be used to provide more useful feedback to the user in the event of an error.

$app->set_header($name,$value)

Adds the specified HTTP header to the list of headers that will be returned with the response.

$app->set_no_cache($bool)

When set to true, signals to the browser that the results should not be cached locally by the browser. This forces the browser to re-download and re-render the page.

Back

Leave a Comment