Skip to content
This repository was archived by the owner on Jan 23, 2020. It is now read-only.

Latest commit

 

History

History
56 lines (41 loc) · 1.91 KB

File metadata and controls

56 lines (41 loc) · 1.91 KB

$Response - is system object, that provides unified target for all needed response data, instance can be obtained in such way:

$Response = \cs\Response::instance();
###[Up](#) Methods

$Response object has next public method:

  • init()
  • init_with_typical_default_settings()
  • header()
  • redirect()
  • cookie()
  • output_default()

Initialize response object with specified data

init_with_typical_default_settings() : \cs\Response

Initialize with typical default settings (headers Content-Type and Vary, protocol taken from cs\Request::$protocol)

header($field : string, $value : string, $replace = true : bool) : \cs\Response

Set raw HTTP header

redirect($location : string, $code = 302 : int) : \cs\Response

Make redirect to specified location

cookie($name : string, $value : string, $expire = 0 : int, $httponly = false : bool) : \cs\Response

Function for setting cookies, taking into account cookies prefix. Parameters like in system setcookie() function, but $path, $domain and $secure are skipped, they are detected automatically

output_default()

Provides default output for all the response data using header(), http_response_code() and echo or php://output

###[Up](#) Properties

$Response object has next public properties:

  • code
  • headers
  • body
  • body_stream

HTTP status code

headers

Headers are normalized to lowercase keys with hyphen as separator, for instance: connection, referer, content-type, accept-language

body

String body (is used instead of body_stream in most cases, ignored if body_stream is present)

body_stream

Body in form of stream (might be used instead of body in some cases, if present, body is ignored)