PHP 클래스 lithium\net\http\Message

상속: extends lithium\net\Message
파일 보기 프로젝트 열기: unionofrad/lithium 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$headers array HTTP headers
$protocol string The full protocol: HTTP/1.1
$version string Specification version number

보호된 프로퍼티들

프로퍼티 타입 설명
$_classes array Classes used by Message and its subclasses.
$_type string Content-Type

공개 메소드들

메소드 설명
__construct ( array $config = [] ) : void Constructor. Adds config values to the public properties when a new object is created.
body ( mixed $data = null, array $options = [] ) : array Add data to and compile the HTTP message body, optionally encoding or decoding its parts according to content type.
headers ( string | array $key = null, mixed $value = null, boolean $replace = true ) : mixed Adds, gets or removes one or multiple headers at the same time.
type ( string $type = null ) : string Sets/gets the content type.

보호된 메소드들

메소드 설명
_decode ( string $body ) : mixed Decode the body based on the content type
_encode ( mixed $body ) : string Encode the body based on the content type

메소드 상세

__construct() 공개 메소드

Constructor. Adds config values to the public properties when a new object is created.
또한 보기: lithium\net\Message::__construct()
public __construct ( array $config = [] ) : void
$config array The available configuration options are the following. Further options are inherited from the parent class. - `'protocol'` _string_: Defaults to `null`. - `'version'` _string_: Defaults to `'1.1'`. - `'scheme'` _string_: Overridden and defaulting to `'http'`. - `'headers'` _array_: Defaults to `array()`.
리턴 void

_decode() 보호된 메소드

Decode the body based on the content type
또한 보기: lithium\net\http\Message::type()
protected _decode ( string $body ) : mixed
$body string
리턴 mixed

_encode() 보호된 메소드

Encode the body based on the content type
또한 보기: lithium\net\http\Message::type()
protected _encode ( mixed $body ) : string
$body mixed
리턴 string

body() 공개 메소드

Add data to and compile the HTTP message body, optionally encoding or decoding its parts according to content type.
public body ( mixed $data = null, array $options = [] ) : array
$data mixed
$options array - `'buffer'` _integer_: split the body string - `'encode'` _boolean_: encode the body based on the content type - `'decode'` _boolean_: decode the body based on the content type
리턴 array

headers() 공개 메소드

Header names are not normalized and their casing left untouched. When headers are retrieved no sorting takes place. This behavior is inline with the specification which states header names should be treated in a case-insensitive way. Sorting is suggested but not required. Get single or multiple headers. $request->headers('Content-Type'); // returns 'text/plain' $request->headers(); // returns array('Content-Type: text/plain', ... ) Set single or multiple headers. $request->headers('Content-Type', 'text/plain'); $request->headers(array('Content-Type' => 'text/plain', ...)); Alternatively use full header line. $request->headers('Content-Type: text/plain'); $request->headers(array('Content-Type: text/plain', ...)); Removing single or multiple headers. $request->headers('Content-Type', false); $request->headers(array('Content-Type' => false, ...)); Certain header fields support multiple values. These can be separated by comma or alternatively the header repeated for each value in the list. When explicitly adding a value to an already existing header (that is when $replace is false) an array with those values is kept/created internally. Later when retrieving headers the header will be repeated for each value. Note: Multiple headers of the same name are only valid if the values of that header can be separated by comma as defined in section 4.2 of RFC2616. Replace single or multiple headers $request->headers('Cache-Control', 'no-store'); $request->headers(array('Cache-Control' => 'public')); $request->headers('Cache-Control'); // returns 'public' Merging with existing array headers. Note that new elements are just appended and no sorting takes place. $request->headers('Cache-Control', 'no-store'); $request->headers('Cache-Control', 'no-cache', false); $request->headers(); returns array('Cache-Control: no-store', 'Cache-Control: no-cache') $request->headers('Cache-Control', 'no-store'); $request->headers('Cache-Control', array('no-cache'), false); $request->headers(); returns array('Cache-Control: no-store', 'Cache-Control: no-cache') $request->headers('Cache-Control', 'max-age=0'); $request->headers('Cache-Control', 'no-store, no-cache'); $request->headers(); returns array('Cache-Control: no-store, no-cache')
public headers ( string | array $key = null, mixed $value = null, boolean $replace = true ) : mixed
$key string | array A header name, a full header line (`': '`), or an array of headers to set in `key => value` form.
$value mixed A value to set if `$key` is a string. It can be an array to set multiple headers with the same key. If `null`, returns the value of the header corresponding to `$key`. If `false`, it unsets the header corresponding to `$key`.
$replace boolean Whether to override or add alongside any existing header with the same name.
리턴 mixed When called with just $key provided, the value of a single header or an array of values in case there is multiple headers with this key. When calling the method without any arguments, an array of compiled headers in the form `array(': ', ...)` is returned. All set and replace operations return no value for performance reasons.

type() 공개 메소드

Sets/gets the content type.
public type ( string $type = null ) : string
$type string A full content type i.e. `'application/json'` or simple name `'json'`
리턴 string A simple content type name, i.e. `'html'`, `'xml'`, `'json'`, etc., depending on the content type of the request.

프로퍼티 상세

$_classes 보호되어 있는 프로퍼티

Classes used by Message and its subclasses.
protected array $_classes
리턴 array

$_type 보호되어 있는 프로퍼티

Content-Type
protected string $_type
리턴 string

$headers 공개적으로 프로퍼티

HTTP headers
public array $headers
리턴 array

$protocol 공개적으로 프로퍼티

The full protocol: HTTP/1.1
public string $protocol
리턴 string

$version 공개적으로 프로퍼티

Specification version number
public string $version
리턴 string