Commit ad5fc100 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Merge branch 'update-httpp'

parents 09fb1ce1 6492a456
This diff is collapsed.
......@@ -33,12 +33,19 @@
#define HTTPP_VAR_VERSION "__version"
#define HTTPP_VAR_URI "__uri"
#define HTTPP_VAR_RAWURI "__rawuri"
#define HTTPP_VAR_QUERYARGS " __queryargs"
#define HTTPP_VAR_QUERYARGS "__queryargs"
#define HTTPP_VAR_REQ_TYPE "__req_type"
#define HTTPP_VAR_ERROR_MESSAGE "__errormessage"
#define HTTPP_VAR_ERROR_CODE "__errorcode"
#define HTTPP_VAR_ICYPASSWORD "__icy_password"
typedef enum {
HTTPP_NS_VAR,
HTTPP_NS_HEADER,
HTTPP_NS_QUERY_STRING,
HTTPP_NS_POST_BODY
} httpp_ns_t;
typedef enum httpp_request_type_tag {
/* Initial and internally used state of the engine */
httpp_req_none = 0,
......@@ -61,10 +68,20 @@ typedef enum httpp_request_type_tag {
httpp_req_unknown
} httpp_request_type_e;
typedef struct http_var_tag {
typedef unsigned int httpp_request_info_t;
#define HTTPP_REQUEST_IS_SAFE ((httpp_request_info_t)0x0001U)
#define HTTPP_REQUEST_IS_IDEMPOTENT ((httpp_request_info_t)0x0002U)
#define HTTPP_REQUEST_IS_CACHEABLE ((httpp_request_info_t)0x0004U)
#define HTTPP_REQUEST_HAS_RESPONSE_BODY ((httpp_request_info_t)0x0010U)
#define HTTPP_REQUEST_HAS_REQUEST_BODY ((httpp_request_info_t)0x0100U)
#define HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY ((httpp_request_info_t)0x0200U)
typedef struct http_var_tag http_var_t;
struct http_var_tag {
char *name;
char *value;
} http_var_t;
size_t values;
char **value;
};
typedef struct http_varlist_tag {
http_var_t var;
......@@ -72,6 +89,7 @@ typedef struct http_varlist_tag {
} http_varlist_t;
typedef struct http_parser_tag {
size_t refc;
httpp_request_type_e req_type;
char *uri;
avl_tree *vars;
......@@ -80,6 +98,7 @@ typedef struct http_parser_tag {
} http_parser_t;
#ifdef _mangle
# define httpp_request_info _mangle(httpp_request_info)
# define httpp_create_parser _mangle(httpp_create_parser)
# define httpp_initialize _mangle(httpp_initialize)
# define httpp_parse _mangle(httpp_parse)
......@@ -97,6 +116,8 @@ typedef struct http_parser_tag {
# define httpp_clear _mangle(httpp_clear)
#endif
httpp_request_info_t httpp_request_info(httpp_request_type_e req);
http_parser_t *httpp_create_parser(void);
void httpp_initialize(http_parser_t *parser, http_varlist_t *defaults);
int httpp_parse(http_parser_t *parser, const char *http_data, unsigned long len);
......@@ -111,8 +132,13 @@ const char *httpp_get_query_param(http_parser_t *parser, const char *name);
void httpp_set_post_param(http_parser_t *parser, const char *name, const char *value);
const char *httpp_get_post_param(http_parser_t *parser, const char *name);
const char *httpp_get_param(http_parser_t *parser, const char *name);
void httpp_destroy(http_parser_t *parser);
void httpp_clear(http_parser_t *parser);
const http_var_t *httpp_get_param_var(http_parser_t *parser, const char *name);
const http_var_t *httpp_get_any_var(http_parser_t *parser, httpp_ns_t ns, const char *name);
char ** httpp_get_any_key(http_parser_t *parser, httpp_ns_t ns);
void httpp_free_any_key(char **keys);
int httpp_addref(http_parser_t *parser);
int httpp_release(http_parser_t *parser);
#define httpp_destroy(x) httpp_release((x))
/* util functions */
httpp_request_type_e httpp_str_to_method(const char * method);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment