PHP WebSocket2 Library
PHP5 Library for browsing web
|
Base class for socket ans proxy implementations. More...
Public Member Functions | |
__destruct () | |
Destructor. | |
sendRequest (WebRequest $request) | |
Sends request to socket and returns response. More... | |
writeRaw ($request) | |
Writes raw data to socket. More... | |
Protected Member Functions | |
open ($address, $port) | |
Opens socket. More... | |
read ($size) | |
Reads raw data from socket. More... | |
close () | |
Closes socket. | |
isOpen () | |
Returns true if socket is open. More... | |
readChunked ($headers, WebRequest $request) | |
Reads chunked content from socket and puts chunks to single string. More... | |
readLength ($length, $headers, WebRequest $request, &$aborted) | |
Reads data with specified length from socket. If socket closes connection or no more data is available to reach length, throws WebRequestException. More... | |
readAll ($headers, WebRequest $request) | |
Reads all available data from socket until it closes connection. More... | |
readUntil ($text) | |
Reads all available data from socket until specified substring is found inside contents. More... | |
readHeaders () | |
Reads response headers. More... | |
write (WebRequest $request) | |
Writes request to socket. More... | |
Base class for socket ans proxy implementations.
|
abstractprotected |
Returns true if socket is open.
bool | True if socket is open |
|
abstractprotected |
Opens socket.
string | $address | Hostname or IPv4 address |
int | $port | Port |
WebRequestException | in case of errors |
|
abstractprotected |
Reads raw data from socket.
int | $size | Size of data in bytes to read |
string | Data that was read from socket |
WebRequestException | in case of errors |
|
abstractprotected |
Reads all available data from socket until it closes connection.
string | $headers | HTTP response headers |
WebRequest | $request | Original request |
string | Raw response data string (or null when OnReceiveBodyCallback is set and returns false, see NetworkSocket::setOnReceiveBodyCallback) |
WebRequestException | in case of errors |
|
protected |
Reads chunked content from socket and puts chunks to single string.
string | $headers | HTTP response headers |
WebRequest | $request | Original request |
string | Raw response data string (or null when OnReceiveBodyCallback is set and returns false, see NetworkSocket::setOnReceiveBodyCallback) |
WebRequestException | in case of errors |
|
protected |
Reads response headers.
string | Raw response headers string |
WebRequestException | in case of errors |
|
abstractprotected |
Reads data with specified length from socket. If socket closes connection or no more data is available to reach length, throws WebRequestException.
int | $length | Data length |
string | $headers | HTTP response headers |
WebRequest | $request | Original request |
bool_reference | $aborted | Will be set to true if function was aborted from callback (see NetworkSocket::setOnReceiveBodyCallback) |
string | Raw response data string (or null when OnReceiveBodyCallback is set and returns false, see NetworkSocket::setOnReceiveBodyCallback) |
WebRequestException | in case of errors |
|
protected |
Reads all available data from socket until specified substring is found inside contents.
string | $text | Substring to search for |
string | Raw response data string |
WebRequestException | in case of errors |
|
abstract |
Sends request to socket and returns response.
Supports HTTP/1.0 and HTTP/1.1 (close and keep-alive connections), chunked contents, gzipped contents.
See also NetworkSocket::setOnReceiveHeadersCallback, NetworkSocket::setOnReceiveBodyCallback.
WebResponse | Callback response |
WebRequestException | in case of errors |
|
protected |
Writes request to socket.
WebRequest | $request | Request to write |
WebRequestException | in case of errors |
|
abstract |
Writes raw data to socket.
string | $request | Raw data |
WebRequestException | in case of errors |