Amiro.CMS API Reference
Amiro.Ru / Manual
Loading search...

The AMI_HTTPResponse class

• Introduction

HTTP response.

• Class synopsis

AMI_HTTPResponse {
/* Methods */
// Adds/replaces HTTP header.
public addHeader ( string $header, [ bool $bReplace = true ], [ int $code = null ] ) returns AMI_HTTPResponse;
// Adds "200 Ok" HTTP header.
public addHeader200 ( ) returns AMI_HTTPResponse;
// Deletes HTTP header.
public deleteHeader ( string $header ) returns AMI_HTTPResponse;
// Returns server protocol.
public getProtocol ( ) returns string;
// Sets HTTP content type.
public setContentType ( string $type ) returns AMI_HTTPResponse;
// Sets a cookie.
public setCookie ( string $name, string $value, [ string $expire = FALSE ], [ string $path = FALSE ] ) returns AMI_HTTPResponse;
// Adds "404 Not Found" HTTP header.
public setHeader404 ( ) returns AMI_HTTPResponse;
// Sends redirect header for HTML response mode.
public setRedirect ( string $location, [ int $code = 302 ] ) returns this;
}

• Class Methods

// Adds/replaces HTTP header.
public addHeader ( string $header, [ bool $bReplace = true ], [ int $code = null ] ) returns AMI_HTTPResponse;
  • string $header
    HTTP header
  • bool $bReplace
    Indicates whether the header should replace a previous similar header, or add a second header of the same type
  • int $code
    Forces the HTTP response code to the specified value
  Example:
Tags:
link php:header()
// Adds "200 Ok" HTTP header.
public addHeader200 ( ) returns AMI_HTTPResponse;
Tags:
since 7.0.0
// Deletes HTTP header.
public deleteHeader ( string $header ) returns AMI_HTTPResponse;
  • string $header
    HTTP header
Tags:
since 7.0.0
// Returns server protocol.
public getProtocol ( ) returns string;
// Sets HTTP content type.
public setContentType ( string $type ) returns AMI_HTTPResponse;
  • string $type
    HTTP contetnt type
  Example:
// Sets a cookie.
public setCookie ( string $name, string $value, [ string $expire = FALSE ], [ string $path = FALSE ] ) returns AMI_HTTPResponse;
  • string $name
    Cookie name
  • string $value
    Cookie value
  • string $expire
    Cookie expiration date (Unix timestamp)
  • string $path
    Cookie save path
Tags:
since 5.12.4
// Adds "404 Not Found" HTTP header.
public setHeader404 ( ) returns AMI_HTTPResponse;
Tags:
since 7.0.0
// Sends redirect header for HTML response mode.
public setRedirect ( string $location, [ int $code = 302 ] ) returns this;
  • string $location
    Redirect location
  • int $code
    Redirect code