Response
in package
Class contains methods to send response to client and close connection
Table of Contents
- $ClientNonBlockMode : bool
- $DataSendTimeout : int
- $IgnoreConnectionLost : bool
- $PacketFragmentationSize : int
- End() : bool
- Adds response for client and closes connection
- Header() : void
- Adds header for response
- IsClosed() : bool
- Returns TRUE if connection closed
- IsConnectionAborted() : bool
- Returns TRUE if client aborted connection
- PrintBody() : bool
- Adds plain text to response body
- PrintHeaders() : bool
- Sends all set headers to client
- SetCookie() : void
- Status() : void
- Sets HTTP-status
Properties
$ClientNonBlockMode
public
bool
$ClientNonBlockMode
= false
Enables client non-block mode. It means that server won't wait when client will receive data. WARNING!!! USE THIS PARAMETER CAREFULLY! IT CAN MAKE SERVER BEHAVIOR NON-OBVIOUS OR UNPREDICTABLE! IF YOU WANT TO SEND A BIG DATA, SEND EVERY ~8KB
$DataSendTimeout
public
int
$DataSendTimeout
= 0
Maximum waiting time in milliseconds for data to be sent to the client
$IgnoreConnectionLost
public
static bool
$IgnoreConnectionLost
= true
If true
, methods End
, PrintBody
and PrintHeaders
won't throw an exception on failure, but will return false
$PacketFragmentationSize
public
static int
$PacketFragmentationSize
= 65536
Sets a size of packet fragmentation. Set 0 for disable fragmentation
Methods
End()
Adds response for client and closes connection
public
End([string $message = "" ]) : bool
Parameters
- $message : string = ""
Tags
Return values
bool —TRUE
if success, FALSE
on any error.
Header()
Adds header for response
public
Header(string $header, string $value) : void
Parameters
- $header : string
- $value : string
Tags
Return values
void —IsClosed()
Returns TRUE if connection closed
public
IsClosed() : bool
Return values
bool —IsConnectionAborted()
Returns TRUE if client aborted connection
public
IsConnectionAborted() : bool
Return values
bool —PrintBody()
Adds plain text to response body
public
PrintBody(string $plainText) : bool
Parameters
- $plainText : string
Tags
Return values
bool —TRUE
if success, FALSE
on any error. Pay attention, if server fails to send message to client, request will be automatically closed
PrintHeaders()
Sends all set headers to client
public
PrintHeaders() : bool
Tags
Return values
bool —TRUE
if success, FALSE
on any error. Pay attention, if server fails to send message to client, request will be automatically closed
SetCookie()
public
SetCookie(string $name, string $value, int $expires[, string $domain = "" ][, string $path = "" ][, bool $secure = false ]) : void
Parameters
- $name : string
-
Cookie name
- $value : string
-
Cookie value
- $expires : int
-
In unixtime
- $domain : string = ""
- $path : string = ""
- $secure : bool = false
Tags
Return values
void —Status()
Sets HTTP-status
public
Status(int $status) : void
Parameters
- $status : int