UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
anonymous_namespace{httpparser.cpp} Namespace Reference

Enumerations

enum  token_type_t {
  TT_IDENTIFIER , TT_WHITESPACE , TT_CRLF , TT_CTRL ,
  TT_SEPARATOR , TT_QUOTEDSTRING
}
 Used to represent different types of tokens in input. More...
 

Functions

void scanner_init (scanner_t *scanner, membuffer *bufptr)
 Initialize scanner.
 
int is_separator_char (int c)
 Determines if the passed value is a separator.
 
int is_identifier_char (int c)
 Determines if the passed value is permissible in token.
 
int is_control_char (int c)
 Determines if the passed value is a control character.
 
int is_qdtext_char (int c)
 Determines if the passed value is permissible in qdtext.
 
parse_status_t scanner_get_token (scanner_t *scanner, memptr *token, token_type_t *tok_type)
 Reads next token from the input stream.
 
char * scanner_get_str (scanner_t *scanner)
 Get pointer to next character in string.
 
int httpmsg_compare (void *param1, void *param2)
 Compares name id in the http headers.
 
void httpheader_free (void *msg)
 Free memory allocated for the http header.
 
parse_status_t skip_blank_lines (scanner_t *scanner)
 Skips blank lines at the start of a msg.
 
parse_status_t skip_lws (scanner_t *scanner)
 Skip linear whitespace.
 
parse_status_t match_non_ws_string (scanner_t *scanner, memptr *str)
 Match a string without whitespace or CRLF (S)
 
parse_status_t match_raw_value (scanner_t *scanner, memptr *raw_value)
 Matches a raw value in a the input.
 
parse_status_t match_int (scanner_t *scanner, int base, int *value)
 Matches an unsigned integer value in the input.
 
parse_status_t read_until_crlf (scanner_t *scanner, memptr *str)
 Reads data until end of line.
 
parse_status_t match_char (scanner_t *scanner, char c, int case_sensitive)
 Compares a character to the next char in the scanner.
 
parse_status_t vfmatch (scanner_t *scanner, const char *fmt, va_list argp)
 Extracts variable parameters depending on the passed in format parameter.
 
parse_status_t match (scanner_t *scanner, const char *fmt,...)
 Matches a variable parameter list and takes necessary actions based on the data type specified.
 
void httpmsg_init (http_message_t *msg)
 Initialize and allocate memory for http message.
 
void parser_init (http_parser_t *parser)
 Initializes the parser object.
 
parse_status_t parser_parse_requestline (http_parser_t *parser)
 Get HTTP Method, URL location and version information.
 
parse_status_t parser_parse_entity_using_clen (http_parser_t *parser)
 Reads entity using content-length.
 
parse_status_t parser_parse_chunky_body (http_parser_t *parser)
 Read data in the chunks.
 
parse_status_t parser_parse_chunky_headers (http_parser_t *parser)
 Read headers at the end of the chunked entity.
 
parse_status_t parser_parse_chunky_entity (http_parser_t *parser)
 Read entity using chunked transfer encoding.
 
parse_status_t parser_parse_entity_until_close (http_parser_t *parser)
 Keep reading entity until the connection is closed.
 

Variables

constexpr std::array< const UPnPsdk::str_int_entry, 11 > Http_Method_Table
 Defines the HTTP methods.
 

Enumeration Type Documentation

◆ token_type_t

enum anonymous_namespace{httpparser.cpp}::token_type_t

Used to represent different types of tokens in input.

Definition at line 64 of file httpparser.cpp.

Function Documentation

◆ scanner_init()

void anonymous_namespace{httpparser.cpp}::scanner_init ( scanner_t scanner,
membuffer bufptr 
)
inline

Initialize scanner.

Parameters
[out]scannerScanner Object to be initialized
[in]bufptrBuffer to be copied

Definition at line 100 of file httpparser.cpp.

+ Here is the caller graph for this function:

◆ is_separator_char()

int anonymous_namespace{httpparser.cpp}::is_separator_char ( int  c)
inline

Determines if the passed value is a separator.

Parameters
[in]cCharacter to be tested against used separator values

Definition at line 112 of file httpparser.cpp.

+ Here is the caller graph for this function:

◆ is_identifier_char()

int anonymous_namespace{httpparser.cpp}::is_identifier_char ( int  c)
inline

Determines if the passed value is permissible in token.

Parameters
[in]cCharacter to be tested for separator values

Definition at line 121 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_control_char()

int anonymous_namespace{httpparser.cpp}::is_control_char ( int  c)
inline

Determines if the passed value is a control character.

Parameters
[in]cCharacter to be tested for a control character

Definition at line 130 of file httpparser.cpp.

+ Here is the caller graph for this function:

◆ is_qdtext_char()

int anonymous_namespace{httpparser.cpp}::is_qdtext_char ( int  c)
inline

Determines if the passed value is permissible in qdtext.

Parameters
[in]cCharacter to be tested for CR/LF

Definition at line 139 of file httpparser.cpp.

+ Here is the caller graph for this function:

◆ scanner_get_token()

parse_status_t anonymous_namespace{httpparser.cpp}::scanner_get_token ( scanner_t scanner,
memptr token,
token_type_t tok_type 
)

Reads next token from the input stream.

0 and is used as a marker, and will not be valid in a quote.

Returns
On success: PARSE_OK
On error:
  • PARSE_INCOMPLETE - not enough chars to get a token
  • PARSE_FAILURE - bad msg format
Parameters
[in,out]scannerScanner Object
[out]tokenToken
[out]tok_typeType of token

Definition at line 160 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scanner_get_str()

char * anonymous_namespace{httpparser.cpp}::scanner_get_str ( scanner_t scanner)
inline

Get pointer to next character in string.

Returns
Pointer to next character in string
Parameters
[in]scannerScanner Object

Definition at line 277 of file httpparser.cpp.

+ Here is the caller graph for this function:

◆ httpmsg_compare()

int anonymous_namespace{httpparser.cpp}::httpmsg_compare ( void *  param1,
void *  param2 
)

Compares name id in the http headers.

Returns
true - if name_id of header1 is equal name_id of header2
false - otherwise
Parameters
[in]param1Pointer to a HTTP header
[in]param2Pointer to a HTTP header

Definition at line 290 of file httpparser.cpp.

+ Here is the caller graph for this function:

◆ httpheader_free()

void anonymous_namespace{httpparser.cpp}::httpheader_free ( void *  msg)

Free memory allocated for the http header.

Parameters
[in]msgPointer to HTTP header.

Definition at line 304 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ skip_blank_lines()

parse_status_t anonymous_namespace{httpparser.cpp}::skip_blank_lines ( scanner_t scanner)
inline

Skips blank lines at the start of a msg.

Returns
On success: PARSE_OK
On error:
  • PARSE_INCOMPLETE - not enough chars to get a token
  • PARSE_FAILURE - bad msg format
Parameters
[in,out]scannerScanner Object

Definition at line 324 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ skip_lws()

parse_status_t anonymous_namespace{httpparser.cpp}::skip_lws ( scanner_t scanner)
inline

Skip linear whitespace.

Returns
On success: PARSE_OK - (LWS)* removed from input
On error:
  • PARSE_FAILURE - bad input
  • PARSE_INCOMPLETE - incomplete input
Parameters
[in,out]scannerScanner Object

Definition at line 353 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ match_non_ws_string()

parse_status_t anonymous_namespace{httpparser.cpp}::match_non_ws_string ( scanner_t scanner,
memptr str 
)
inline

Match a string without whitespace or CRLF (S)

Returns
On success: PARSE_OK
On error:
  • PARSE_NO_MATCH
  • PARSE_FAILURE
  • PARSE_INCOMPLETE
Parameters
[in,out]scannerScanner Object.
[out]strBuffer to get the scanner buffer contents.

Definition at line 402 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ match_raw_value()

parse_status_t anonymous_namespace{httpparser.cpp}::match_raw_value ( scanner_t scanner,
memptr raw_value 
)
inline

Matches a raw value in a the input.

Value's length can be 0 or more. Whitespace after value is trimmed. On success, scanner points the CRLF that ended the value.

Returns
On success: PARSE:_OK
On error:
  • PARSE_INCOMPLETE
  • PARSE_FAILURE
Parameters
[in,out]scannerScanner Object
[out]raw_valueBuffer to get the scanner buffer.

Definition at line 463 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ match_int()

parse_status_t anonymous_namespace{httpparser.cpp}::match_int ( scanner_t scanner,
int  base,
int *  value 
)
inline

Matches an unsigned integer value in the input.

The integer is returned in 'value'. Except for PARSE_OK result, the scanner's cursor is moved back to its original position on error.

Returns
On success: PARSE_OK On error:
  • PARSE_NO_MATCH - got different kind of token
  • PARSE_FAILURE - bad input
  • PARSE_INCOMPLETE
Parameters
[in,out]scannerScanner Object.
[in]baseBase of number in the string; valid values: 10 or 16.
[out]valueNumber stored here.

Definition at line 549 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_until_crlf()

parse_status_t anonymous_namespace{httpparser.cpp}::read_until_crlf ( scanner_t scanner,
memptr str 
)
inline

Reads data until end of line.

The crlf at the end of line is not consumed. On error, scanner is not restored. On success, str points to a string that runs until eol.

Returns
On success: PARSE_OK
On error:
  • PARSE_FAILURE
  • PARSE_INCOMPLETE
Parameters
[in,out]scannerScanner Object.
[out]strBuffer to copy scanner buffer contents to.

Definition at line 600 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ match_char()

parse_status_t anonymous_namespace{httpparser.cpp}::match_char ( scanner_t scanner,
char  c,
int  case_sensitive 
)
inline

Compares a character to the next char in the scanner.

On error, scanner chars are not restored.

Returns
On success: PARSE_OK
On error:
  • PARSE_NO_MATCH
  • PARSE_INCOMPLETE
Parameters
[in,out]scannerScanner Object.
[in]cCharacter to be compared with.
[in]case_sensitiveFlag indicating whether comparison should be case sensitive.

Definition at line 641 of file httpparser.cpp.

+ Here is the caller graph for this function:

◆ vfmatch()

parse_status_t anonymous_namespace{httpparser.cpp}::vfmatch ( scanner_t scanner,
const char *  fmt,
va_list  argp 
)

Extracts variable parameters depending on the passed in format parameter.

Parses data also based on the passed in format parameter.

Returns
On success: PARSE_OK
On error:
  • PARSE_INCOMPLETE
  • PARSE_FAILURE - bad input
  • PARSE_NO_MATCH - input does not match pattern
Parameters
[in,out]scannerScanner Object.
[in]fmtPattern Format.
[in]argpList of variable arguments.

Definition at line 710 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ match()

parse_status_t anonymous_namespace{httpparser.cpp}::match ( scanner_t scanner,
const char *  fmt,
  ... 
)

Matches a variable parameter list and takes necessary actions based on the data type specified.

Returns
On success: PARSE_OK
On error:
  • PARSE_OK
  • PARSE_NO_MATCH
  • PARSE_INCOMPLETE
  • PARSE_FAILURE - bad input
Parameters
[in,out]scannerScanner Object.
[in]fmtPattern format (like printf()).
[in]...Variable arguments (like printf()).

Definition at line 882 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ httpmsg_init()

void anonymous_namespace{httpparser.cpp}::httpmsg_init ( http_message_t msg)

Initialize and allocate memory for http message.

Parameters
[in,out]msgHTTP Message Object

Definition at line 900 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parser_init()

void anonymous_namespace{httpparser.cpp}::parser_init ( http_parser_t parser)
inline

Initializes the parser object.

Parameters
[out]parserHTTP Parser Object.

Definition at line 916 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parser_parse_requestline()

parse_status_t anonymous_namespace{httpparser.cpp}::parser_parse_requestline ( http_parser_t parser)

Get HTTP Method, URL location and version information.

Returns
On success: PARSE_OK
On error:
  • PARSE_SUCCESS
  • PARSE_FAILURE
  • PARSE_INCOMPLETE
  • PARSE_NO_MATCH
Parameters
[in,out]parserHTTP Parser Object.

Definition at line 942 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parser_parse_entity_using_clen()

parse_status_t anonymous_namespace{httpparser.cpp}::parser_parse_entity_using_clen ( http_parser_t parser)
inline

Reads entity using content-length.

Returns
On success: PARSE_SUCCESS
On error: PARSE_INCOMPLETE
Parameters
[in,out]parserHTTP Parser Object.

Definition at line 1079 of file httpparser.cpp.

+ Here is the caller graph for this function:

◆ parser_parse_chunky_body()

parse_status_t anonymous_namespace{httpparser.cpp}::parser_parse_chunky_body ( http_parser_t parser)
inline

Read data in the chunks.

Returns
On success: PARSE_CONTINUE_1
On error:
  • PARSE_INCOMPLETE
  • PARSE_FAILURE
  • PARSE_NO_MATCH
Parameters
[in,out]parserHTTP Parser Object.

Definition at line 1125 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parser_parse_chunky_headers()

parse_status_t anonymous_namespace{httpparser.cpp}::parser_parse_chunky_headers ( http_parser_t parser)
inline

Read headers at the end of the chunked entity.

Returns
On success: PARSE_SUCCESS
On error:
  • PARSE_NO_MATCH
  • PARSE_INCOMPLETE
  • PARSE_FAILURE
Parameters
[in,out]parserHTTP Parser Object.

Definition at line 1166 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parser_parse_chunky_entity()

parse_status_t anonymous_namespace{httpparser.cpp}::parser_parse_chunky_entity ( http_parser_t parser)
inline

Read entity using chunked transfer encoding.

Returns
On success: PARSE_CONTINUE_1
On error:
  • PARSE_INCOMPLETE
  • PARSE_FAILURE
  • PARSE_NO_MATCH
Parameters
[in,out]parserHTTP Parser Object.

Definition at line 1202 of file httpparser.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parser_parse_entity_until_close()

parse_status_t anonymous_namespace{httpparser.cpp}::parser_parse_entity_until_close ( http_parser_t parser)
inline

Keep reading entity until the connection is closed.

Returns
always PARSE_INCOMPLETE_ENTITY
Parameters
[in,out]parserHTTP Parser Object.

Definition at line 1247 of file httpparser.cpp.

+ Here is the caller graph for this function:

Variable Documentation

◆ Http_Method_Table

constexpr std::array<const UPnPsdk::str_int_entry, 11> anonymous_namespace{httpparser.cpp}::Http_Method_Table
inlineconstexpr
Initial value:
{
{{"DELETE", HTTPMETHOD_DELETE},
{"GET", HTTPMETHOD_GET},
{"HEAD", HTTPMETHOD_HEAD},
{"M-POST", HTTPMETHOD_MPOST},
{"M-SEARCH", HTTPMETHOD_MSEARCH},
{"NOTIFY", HTTPMETHOD_NOTIFY},
{"POST", HTTPMETHOD_POST},
{"SUBSCRIBE", HTTPMETHOD_SUBSCRIBE},
{"UNSUBSCRIBE", HTTPMETHOD_UNSUBSCRIBE},
{"POST", SOAPMETHOD_POST},
{"PUT", HTTPMETHOD_PUT}}}

Defines the HTTP methods.

Definition at line 75 of file httpparser.cpp.