1#ifndef COMPA_GENLIB_NET_HTTP_HTTPPARSER_HPP
2#define COMPA_GENLIB_NET_HTTP_HTTPPARSER_HPP
58#define ENTREAD_DETERMINE_READ_METHOD 1
59#define ENTREAD_USING_CLEN 2
60#define ENTREAD_USING_CHUNKED 3
61#define ENTREAD_UNTIL_CLOSE 4
62#define ENTREAD_CHUNKY_BODY 5
63#define ENTREAD_CHUNKY_HEADERS 6
99 HTTPMETHOD_UNSUBSCRIBE,
111#define HDR_UNKNOWN -1
112#define HDR_CACHE_CONTROL 1
113#define HDR_CALLBACK 2
114#define HDR_CONTENT_LENGTH 3
115#define HDR_CONTENT_TYPE 4
122#define HDR_LOCATION 11
130#define HDR_SOAPACTION 19
132#define HDR_TIMEOUT 21
133#define HDR_TRANSFER_ENCODING 22
135#define HDR_USER_AGENT 24
142#define HDR_ACCEPT_ENCODING 26
143#define HDR_ACCEPT_CHARSET 27
144#define HDR_ACCEPT_LANGUAGE 28
145#define HDR_ACCEPT_RANGE 29
146#define HDR_CONTENT_ENCODING 30
147#define HDR_CONTENT_LANGUAGE 31
148#define HDR_CONTENT_LOCATION 32
149#define HDR_CONTENT_RANGE 33
150#define HDR_IF_RANGE 34
315 const char* header_name
537 std::string_view log_msg,
parse_status_t parser_parse_headers(http_parser_t *parser)
Get HTTP Method, URL location and version information.
http_message_t msg
entire raw message
#define HDR_CONTENT_ENCODING
Header definition.
uri_type uri
Type of a uri, e.g. absolute, relative, etc.
#define HDR_CONTENT_LOCATION
Header definition.
constexpr std::array< const UPnPsdk::str_int_entry, 33 > Http_Header_Names
Assigns header-name id to its text representation.
http_header_t * httpmsg_find_hdr_str(http_message_t *msg, const char *header_name)
Compares the header name with the header names stored in the linked list of messages.
http_method_t method
Http method of an outgoing request.
int is_request
If 1, msg is a request, else response.
http_method_t
Method in a HTTP request.
memptr name
Header name as a string.
#define HDR_ACCEPT_ENCODING
Header definition.
#define HDR_CONTENT_LANGUAGE
Header definition.
int major_version
Http major version.
parse_status_t parser_parse(http_parser_t *parser)
The parser function.
int entire_msg_loaded
Completeness of 'msg'.
#define HDR_TRANSFER_ENCODING
Type of a HTTP header.
memptr entity
message body(entity).
#define HDR_USN
Type of a HTTP header.
char * urlbuf
storage for url string.
#define HDR_ACCEPT_RANGE
Header definition.
void parser_request_init(http_parser_t *parser)
Initializes parser object for a request.
#define HDR_DATE
Type of a HTTP header.
#define HDR_NT
Type of a HTTP header.
#define HDR_MX
Type of a HTTP header.
#define HDR_NTS
Type of a HTTP header.
#define HDR_ACCEPT_LANGUAGE
Header definition.
#define HDR_EXT
Type of a HTTP header.
membuffer value
Raw-value; could be multi-lined; min-length = 0.
size_t amount_discarded
The amount of data that's been read by the user, that's no longer in the raw message buffer.
int raw_find_str(memptr *raw_value, const char *str)
Find a substring from raw character string buffer.
#define HDR_ACCEPT
Header definition.
#define HDR_SERVER
Type of a HTTP header.
membuffer msg
entire raw message.
int http_error_code
read-only; in case of parse error, this contains the HTTP error code (4XX or 5XX).
membuffer name_buf
(Private use – don't touch.)
http_header_t * httpmsg_find_hdr(http_message_t *msg, int header_name_id, memptr *value)
Finds header from a list, with the given 'name_id'.
#define HDR_ST
Type of a HTTP header.
#define HDR_HOST
Type of a HTTP header.
parse_status_t parser_parse_entity(http_parser_t *parser)
Determines method to read entity.
http_method_t request_method
Http method of an incoming response.
#define HDR_ACCEPT_CHARSET
Header definition.
#define HDR_CACHE_CONTROL
Type of a HTTP header.
size_t chunk_size
Private data – don't touch.
#define HDR_CALLBACK
Type of a HTTP header.
parser_pos_t position
Private data – don't touch.
void parser_response_init(http_parser_t *parser, http_method_t request_method)
Initializes parser object for a response.
#define HDR_SEQ
Type of a HTTP header.
membuffer * msg
Raw http message.
#define HDR_LOCATION
Type of a HTTP header.
#define HDR_MAN
Type of a HTTP header.
parse_status_t parser_parse_responseline(http_parser_t *parser)
Get HTTP Method, URL location and version information.
parser_pos_t
Type of a parser position.
@ POS_COMPLETE
Position complete.
@ POS_RESPONSE_LINE
Position response line.
@ POS_ENTITY
Position entity.
@ POS_REQUEST_LINE
Position request line.
@ POS_HEADERS
Position headers.
#define HDR_USER_AGENT
Type of a HTTP header.
void httpmsg_destroy(http_message_t *msg)
Free memory allocated for the http message.
parse_status_t parser_get_entity_read_method(http_parser_t *parser)
Determines method to read entity.
parse_status_t
Status of parsing.
@ PARSE_INCOMPLETE_ENTITY
#define HDR_IF_RANGE
Header definition.
int initialized
Indicates if the object is initialized.
unsigned int content_length
Private data – don't touch.
int raw_to_int(memptr *raw_value, int base)
Converts raw character data to integer value.
int valid_ssdp_notify_hack
read-only; this is set to 1 if a NOTIFY request has no content-length. used to read valid sspd notify...
size_t cursor
Current position in buffer.
#define HDR_SOAPACTION
Type of a HTTP header.
#define HDR_CONTENT_TYPE
Type of a HTTP header.
int name_id
Header name id (for a selective group of headers only).
int ent_position
Private data – don't touch.
LinkedList headers
List of headers.
int minor_version
Http minor version.
parse_status_t parser_append(http_parser_t *parser, const char *buf, size_t buf_length)
Append date to HTTP parser, and do the parsing.
parse_status_t matchstr(char *str, size_t slen, const char *fmt,...)
Matches a variable parameter list with a string and takes actions based on the data type specified.
const char * method_to_str(http_method_t method)
A wrapper function that maps a method id to a method.
void print_http_headers(std::string_view log_msg, http_message_t *hmsg)
Print the HTTP headers.
size_t entity_start_position
Offset in the raw message buffer, which contains the message body. preceding this are the headers of ...
#define HDR_TE
Header definition.
#define HDR_TIMEOUT
Type of a HTTP header.
#define HDR_RANGE
Header definition.
#define HDR_CONTENT_LENGTH
Type of a HTTP header.
#define HDR_SID
Type of a HTTP header.
#define HDR_CONTENT_RANGE
Header definition.
Structure of an HTTP parser object.
Structure of a scanner object.
Structure of an HTTP message.
Represents a URI used in parse_uri and elsewhere.
Manage a linked list (for internal use only).
Linked list (no protection).
C++ interface for the Uri module.
@ UPNP_HTTPMETHOD_DELETE
DELETE.
@ UPNP_HTTPMETHOD_GET
GET.
@ UPNP_HTTPMETHOD_HEAD
HEAD.
@ UPNP_HTTPMETHOD_PUT
PUT.
@ UPNP_HTTPMETHOD_POST
POST.
Manage blocks of dynamically allocated memory.
pointer to a chunk of memory.
Maintains a block of dynamically allocated memory.
String to integer and integer to string conversion functions.