mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
Added run-time option to disable cookies parsing
This commit is contained in:
@@ -385,6 +385,24 @@ Comment: Disable #MHD_action_suspend() functionality.
|
||||
+ You should only use this function if you do not use suspend functionality and need a generally minor boost in performance.
|
||||
+ The suspend is not disallowed (suspend is allowed) by default.
|
||||
|
||||
Name: DISABLE_COOKIES
|
||||
Value: 324
|
||||
Type: enum MHD_Bool
|
||||
Comment: Disable cookies parsing.
|
||||
+
|
||||
+ Disable automatic cookies processing if cookies are not used.
|
||||
+ Cookies are automatically parsed by default.
|
||||
CustomSetter: /* custom setter */
|
||||
+ /* The is not an easy for automatic generations */
|
||||
+ // TODO: remove options generator, put preprocessor directives to
|
||||
+ // the first column
|
||||
+ #ifdef MHD_SUPPORT_COOKIES
|
||||
+ settings->disable_cookies = option->val.disable_cookies;
|
||||
+ #else
|
||||
+ if (MHD_NO != option->val.disable_cookies)
|
||||
+ return MHD_SC_FEATURE_DISABLED;
|
||||
+ #endif
|
||||
|
||||
# Notification callbacks
|
||||
|
||||
Name: daemon_ready_callback
|
||||
|
||||
@@ -4399,6 +4399,18 @@ MHD_D_OPTION_DISALLOW_SUSPEND_RESUME (
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
* Disable cookies parsing.
|
||||
*
|
||||
Disable automatic cookies processing if cookies are not used.
|
||||
* Cookies are automatically parsed by default.
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_DISABLE_COOKIES (
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
* Set a callback to be called for pre-start finalisation.
|
||||
*
|
||||
|
||||
@@ -274,6 +274,15 @@ You should only use this function if you do not use suspend functionality and ne
|
||||
MHD_D_O_DISALLOW_SUSPEND_RESUME = 323
|
||||
,
|
||||
|
||||
/**
|
||||
* Disable cookies parsing.
|
||||
*
|
||||
Disable automatic cookies processing if cookies are not used.
|
||||
* Cookies are automatically parsed by default.
|
||||
*/
|
||||
MHD_D_O_DISABLE_COOKIES = 324
|
||||
,
|
||||
|
||||
/**
|
||||
* Set a callback to be called for pre-start finalisation.
|
||||
*
|
||||
@@ -766,6 +775,11 @@ union MHD_DaemonOptionValue
|
||||
*/
|
||||
enum MHD_Bool disallow_suspend_resume;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DISABLE_COOKIES.
|
||||
*/
|
||||
enum MHD_Bool disable_cookies;
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAEMON_READY_CALLBACK.
|
||||
* the pre-start callback
|
||||
@@ -1331,6 +1345,21 @@ You should only use this function if you do not use suspend functionality and ne
|
||||
.val.disallow_suspend_resume = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Disable cookies parsing.
|
||||
*
|
||||
Disable automatic cookies processing if cookies are not used.
|
||||
* Cookies are automatically parsed by default.
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DISABLE_COOKIES(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DISABLE_COOKIES, \
|
||||
.val.disable_cookies = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Set a callback to be called for pre-start finalisation.
|
||||
*
|
||||
@@ -2167,6 +2196,27 @@ MHD_D_OPTION_DISALLOW_SUSPEND_RESUME (
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disable cookies parsing.
|
||||
*
|
||||
Disable automatic cookies processing if cookies are not used.
|
||||
* Cookies are automatically parsed by default.
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_DISABLE_COOKIES (
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DISABLE_COOKIES;
|
||||
opt_val.val.disable_cookies = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a callback to be called for pre-start finalisation.
|
||||
*
|
||||
|
||||
@@ -231,6 +231,12 @@ struct DaemonOptions
|
||||
enum MHD_Bool disallow_suspend_resume;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DISABLE_COOKIES.
|
||||
*/
|
||||
enum MHD_Bool disable_cookies;
|
||||
|
||||
|
||||
/**
|
||||
* Value for #MHD_D_O_DAEMON_READY_CALLBACK.
|
||||
* the pre-start callback
|
||||
|
||||
@@ -198,6 +198,18 @@ MHD_daemon_set_options (
|
||||
case MHD_D_O_DISALLOW_SUSPEND_RESUME:
|
||||
settings->disallow_suspend_resume = option->val.disallow_suspend_resume;
|
||||
continue;
|
||||
case MHD_D_O_DISABLE_COOKIES:
|
||||
/* custom setter */
|
||||
/* The is not an easy for automatic generations */
|
||||
// TODO: remove options generator, put preprocessor directives to
|
||||
// the first column
|
||||
#ifdef MHD_SUPPORT_COOKIES
|
||||
settings->disable_cookies = option->val.disable_cookies;
|
||||
#else
|
||||
if (MHD_NO != option->val.disable_cookies)
|
||||
return MHD_SC_FEATURE_DISABLED;
|
||||
#endif
|
||||
continue;
|
||||
case MHD_D_O_DAEMON_READY_CALLBACK:
|
||||
settings->daemon_ready_callback.v_cb = option->val.daemon_ready_callback.v_cb;
|
||||
settings->daemon_ready_callback.v_cb_cls = option->val.daemon_ready_callback.v_cb_cls;
|
||||
|
||||
@@ -129,6 +129,10 @@ daemon_set_basic_settings (struct MHD_Daemon *restrict d,
|
||||
{
|
||||
d->req_cfg.strictness = s->protocol_strict_level.v_sl;
|
||||
|
||||
#ifdef MHD_SUPPORT_COOKIES
|
||||
d->req_cfg.disable_cookies = (MHD_NO != s->disable_cookies);
|
||||
#endif
|
||||
|
||||
d->req_cfg.suppress_date = (MHD_NO != s->suppress_date_header);
|
||||
|
||||
return MHD_SC_OK;
|
||||
|
||||
@@ -940,6 +940,13 @@ struct mhd_DaemonRequestProcessingSettings
|
||||
*/
|
||||
enum MHD_ProtocolStrictLevel strictness;
|
||||
|
||||
#ifdef MHD_SUPPORT_COOKIES
|
||||
/**
|
||||
* Disable automatic cookies parsing
|
||||
*/
|
||||
bool disable_cookies;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Early URI callback
|
||||
*/
|
||||
|
||||
@@ -2745,7 +2745,8 @@ mhd_stream_parse_request_headers (struct MHD_Connection *restrict c)
|
||||
|
||||
#ifdef MHD_SUPPORT_COOKIES
|
||||
/* "Cookie:" */
|
||||
if (mhd_str_equal_caseless_n_st (MHD_HTTP_HEADER_COOKIE,
|
||||
if ((! c->daemon->req_cfg.disable_cookies) &&
|
||||
mhd_str_equal_caseless_n_st (MHD_HTTP_HEADER_COOKIE,
|
||||
f->field.nv.name.cstr,
|
||||
f->field.nv.name.len))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user