Parser
HTTP Response Parser
- Full name:
\SimplePie\HTTP\Parser
Constants
Constant | Visibility | Type | Value |
---|---|---|---|
STATE_HTTP_VERSION |
private | 'http_version' | |
STATE_STATUS |
private | 'status' | |
STATE_REASON |
private | 'reason' | |
STATE_NEW_LINE |
private | 'new_line' | |
STATE_BODY |
private | 'body' | |
STATE_NAME |
private | 'name' | |
STATE_VALUE |
private | 'value' | |
STATE_VALUE_CHAR |
private | 'value_char' | |
STATE_QUOTE |
private | 'quote' | |
STATE_QUOTE_ESCAPED |
private | 'quote_escaped' | |
STATE_QUOTE_CHAR |
private | 'quote_char' | |
STATE_CHUNKED |
private | 'chunked' | |
STATE_EMIT |
private | 'emit' | |
STATE_ERROR |
private | false |
Properties
http_version
HTTP Version
status_code
Status code
reason
Reason phrase
headers
Key/value pairs of the headers
body
Body of the response
state
Current state of the state machine
data
Input data
data_length
Input data length (to avoid calling strlen() everytime this is needed)
position
Current position of the pointer
name
Name of the hedaer currently being parsed
value
Value of the hedaer currently being parsed
Methods
__construct
Create an instance of the class with the input data
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
string | Input data |
parse
Parse the input data
Return Value:
true on success, false on failure
has_data
Check whether there is data beyond the pointer
Return Value:
true if there is further data, false if not
is_linear_whitespace
See if the next character is LWS
Return Value:
true if the next character is LWS, false if not
http_version
Parse the HTTP version
status
Parse the status code
reason
Parse the reason phrase
new_line
Deal with a new line, shifting data around as needed
name
Parse a header name
linear_whitespace
Parse LWS, replacing consecutive LWS characters with a single space
value
See what state to move to while within non-quoted header values
value_char
Parse a header value while outside quotes
quote
See what state to move to while within quoted header values
quote_char
Parse a header value while within quotes
quote_escaped
Parse an escaped character within quotes
body
Parse the body
chunked
Parsed a "Transfer-Encoding: chunked" body
prepareHeaders
Prepare headers (take care of proxies headers)
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$headers |
string | Raw headers |
$count |
int | Redirection count. Default to 1. |
Automatically generated on 2025-03-18