|
|
@@ -7329,16 +7329,125 @@ MHD_action_from_response (struct MHD_Request *request,
|
|
|
struct MHD_Response *response);
|
|
|
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * The `enum MHD_RequestTerminationCode` specifies reasons
|
|
|
+ * why a request has been terminated (or completed).
|
|
|
+ * @ingroup request
|
|
|
+ */
|
|
|
+enum MHD_FIXED_ENUM_MHD_SET_ MHD_RequestTerminationCode
|
|
|
+{
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The response was successfully sent.
|
|
|
+ * @ingroup request
|
|
|
+ */
|
|
|
+ MHD_REQUEST_TERMINATED_COMPLETED_OK = 0
|
|
|
+ ,
|
|
|
+ /**
|
|
|
+ * The application terminated request without response.
|
|
|
+ * @ingroup request
|
|
|
+ */
|
|
|
+ MHD_REQUEST_TERMINATED_BY_APP = 1
|
|
|
+ ,
|
|
|
+ /**
|
|
|
+ * The request is not valid according to
|
|
|
+ * HTTP specifications.
|
|
|
+ * @ingroup request
|
|
|
+ */
|
|
|
+ MHD_REQUEST_TERMINATED_HTTP_PROTOCOL_ERROR = 2
|
|
|
+ ,
|
|
|
+ /**
|
|
|
+ * The client terminated the connection by closing the socket
|
|
|
+ * for writing (TCP half-closed) before sending complete request;
|
|
|
+ * MHD aborted sending the response according to RFC 2616, section 8.1.4.
|
|
|
+ * @ingroup request
|
|
|
+ */
|
|
|
+ MHD_REQUEST_TERMINATED_CLIENT_ABORT = 3
|
|
|
+ ,
|
|
|
+ /**
|
|
|
+ * Error handling the connection due to resources exhausted.
|
|
|
+ * @ingroup request
|
|
|
+ */
|
|
|
+ MHD_REQUEST_TERMINATED_NO_RESOURCES = 4
|
|
|
+ ,
|
|
|
+ /**
|
|
|
+ * We had to close the session since MHD was being shut down.
|
|
|
+ * @ingroup request
|
|
|
+ */
|
|
|
+ MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 5
|
|
|
+ ,
|
|
|
+ /**
|
|
|
+ * No activity on the connection for the number of seconds specified using
|
|
|
+ * #MHD_C_OPTION_TIMEOUT().
|
|
|
+ * @ingroup request
|
|
|
+ */
|
|
|
+ MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 6
|
|
|
+ ,
|
|
|
+ /**
|
|
|
+ * The connection was broken or TLS protocol error.
|
|
|
+ * @ingroup request
|
|
|
+ */
|
|
|
+ MHD_REQUEST_TERMINATED_CONNECTION_ERROR = 7
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * Additional information about request termination
|
|
|
+ */
|
|
|
+union MHD_RequestTerminationDetail
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * Reserved member.
|
|
|
+ * Do not use.
|
|
|
+ */
|
|
|
+ void *reserved;
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * Request termination data structure
|
|
|
+ */
|
|
|
+struct MHD_RequestTerminationData
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * The code of the event
|
|
|
+ */
|
|
|
+ enum MHD_RequestTerminationCode code;
|
|
|
+ /**
|
|
|
+ * Detailed information about termination event
|
|
|
+ */
|
|
|
+ union MHD_RequestTerminationDetail details;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * Flags for special handling of responses.
|
|
|
+ * Signature of the callback used by MHD to notify the application
|
|
|
+ * about completed requests.
|
|
|
+ *
|
|
|
+ * @param cls client-defined closure
|
|
|
+ * @param data the details about the event
|
|
|
+ * @param request_context request context value, as originally
|
|
|
+ * returned by the #MHD_EarlyUriLogCallback
|
|
|
+ * @see #MHD_option_request_completion()
|
|
|
+ * @ingroup request
|
|
|
+ */
|
|
|
+typedef void
|
|
|
+(*MHD_RequestTerminationCallback) (void *cls,
|
|
|
+ struct MHD_RequestTerminationData *data,
|
|
|
+ void *request_context);
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * The options (parameters) for responses.
|
|
|
*/
|
|
|
-enum MHD_ResponseOptionBool
|
|
|
+enum MHD_FIXED_ENUM_APP_SET_ MHD_ResponseOption
|
|
|
{
|
|
|
/**
|
|
|
* Not a real option, terminate the list of options
|
|
|
*/
|
|
|
- MHD_RESP_OPT_BOOL_END = 0
|
|
|
+ MHD_R_O_END = 0
|
|
|
,
|
|
|
+
|
|
|
+ /* = MHD Response Option enum values below are generated automatically = */
|
|
|
/**
|
|
|
* Make the response object re-usable.
|
|
|
* The response will not be consumed by MHD_action_from_response() and
|
|
|
@@ -7417,166 +7526,186 @@ enum MHD_ResponseOptionBool
|
|
|
* header is undesirable in response to HEAD requests.
|
|
|
*/
|
|
|
MHD_RESP_OPT_BOOL_HEAD_ONLY_RESPONSE = 81
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-// FIXME: use the same approach as for the daemon
|
|
|
-MHD_EXTERN_ enum MHD_StatusCode
|
|
|
-MHD_response_set_option_bool (struct MHD_Response *response,
|
|
|
- enum MHD_ResponseOption ro,
|
|
|
- enum MHD_Bool value)
|
|
|
-MHD_FN_PAR_NONNULL_ALL_;
|
|
|
+ ,
|
|
|
+ /* = MHD Response Option enum values above are generated automatically = */
|
|
|
|
|
|
-// FIXME: the suggested approach
|
|
|
+ /* * Sentinel * */
|
|
|
+ /**
|
|
|
+ * The sentinel value.
|
|
|
+ * This value enforces specific underlying integer type for the enum.
|
|
|
+ * Do not use.
|
|
|
+ */
|
|
|
+ MHD_R_O_SENTINEL = 65535
|
|
|
|
|
|
-struct MHD_ResponseOptionBoolSet
|
|
|
-{
|
|
|
- enum MHD_ResponseOptionBool option;
|
|
|
- enum MHD_Bool value;
|
|
|
};
|
|
|
|
|
|
-// FIXME: fully type-safe, options array can be built incrementally
|
|
|
-// See https://github.com/babelouest/ulfius/blob/1ed26069fd7e1decd38e8d403a5649b0337893ff/src/ulfius.c#L1073
|
|
|
-// for incrementally built options
|
|
|
+/* = MHD Response Option structures below are generated automatically = */
|
|
|
+
|
|
|
+/* = MHD Response Option structures above are generated automatically = */
|
|
|
|
|
|
/**
|
|
|
- * Set several options for the response object
|
|
|
- * @param response the response to set the options
|
|
|
- * @param options_array the pointer to the array with the options;
|
|
|
- * the array is read until first ::MHD_RESP_OPT_BOOL_END
|
|
|
- * option, but not more than @a max_num_options elements
|
|
|
- * @param max_num_options the maximum number of elements to read
|
|
|
- * from @a options_array, ignored if set to SIZE_MAX
|
|
|
- * @return #MHD_SC_OK if found,
|
|
|
- * error code otherwise
|
|
|
+ * Parameters for response options
|
|
|
*/
|
|
|
-MHD_EXTERN_ enum MHD_StatusCode
|
|
|
-MHD_response_set_options_bool (struct MHD_Response *response,
|
|
|
- struct MHD_ResponseOptionBoolSet *options_array,
|
|
|
- size_t max_num_options)
|
|
|
-MHD_FN_PAR_NONNULL_ALL_;
|
|
|
+union MHD_ResponseOptionValue
|
|
|
+{
|
|
|
+ /* = MHD Response Option union members below are generated automatically = */
|
|
|
|
|
|
+ /* = MHD Response Option union members above are generated automatically = */
|
|
|
+};
|
|
|
|
|
|
/**
|
|
|
- * The `enum MHD_RequestTerminationCode` specifies reasons
|
|
|
- * why a request has been terminated (or completed).
|
|
|
- * @ingroup request
|
|
|
+ * Combination of response option with parameters values
|
|
|
*/
|
|
|
-enum MHD_FIXED_ENUM_MHD_SET_ MHD_RequestTerminationCode
|
|
|
+struct MHD_ResponseOptionAndValue
|
|
|
{
|
|
|
-
|
|
|
- /**
|
|
|
- * The response was successfully sent.
|
|
|
- * @ingroup request
|
|
|
- */
|
|
|
- MHD_REQUEST_TERMINATED_COMPLETED_OK = 0
|
|
|
- ,
|
|
|
- /**
|
|
|
- * The application terminated request without response.
|
|
|
- * @ingroup request
|
|
|
- */
|
|
|
- MHD_REQUEST_TERMINATED_BY_APP = 1
|
|
|
- ,
|
|
|
- /**
|
|
|
- * The request is not valid according to
|
|
|
- * HTTP specifications.
|
|
|
- * @ingroup request
|
|
|
- */
|
|
|
- MHD_REQUEST_TERMINATED_HTTP_PROTOCOL_ERROR = 2
|
|
|
- ,
|
|
|
- /**
|
|
|
- * The client terminated the connection by closing the socket
|
|
|
- * for writing (TCP half-closed) before sending complete request;
|
|
|
- * MHD aborted sending the response according to RFC 2616, section 8.1.4.
|
|
|
- * @ingroup request
|
|
|
- */
|
|
|
- MHD_REQUEST_TERMINATED_CLIENT_ABORT = 3
|
|
|
- ,
|
|
|
- /**
|
|
|
- * Error handling the connection due to resources exhausted.
|
|
|
- * @ingroup request
|
|
|
- */
|
|
|
- MHD_REQUEST_TERMINATED_NO_RESOURCES = 4
|
|
|
- ,
|
|
|
/**
|
|
|
- * We had to close the session since MHD was being shut down.
|
|
|
- * @ingroup request
|
|
|
+ * The response configuration option
|
|
|
*/
|
|
|
- MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 5
|
|
|
- ,
|
|
|
+ enum MHD_ResponseOption opt;
|
|
|
/**
|
|
|
- * No activity on the connection for the number of seconds specified using
|
|
|
- * #MHD_C_OPTION_TIMEOUT().
|
|
|
- * @ingroup request
|
|
|
- */
|
|
|
- MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 6
|
|
|
- ,
|
|
|
- /**
|
|
|
- * The connection was broken or TLS protocol error.
|
|
|
- * @ingroup request
|
|
|
+ * The value for the @a opt option
|
|
|
*/
|
|
|
- MHD_REQUEST_TERMINATED_CONNECTION_ERROR = 7
|
|
|
+ union MHD_ResponseOptionValue val;
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#if defined(MHD_USE_COMPOUND_LITERALS) && defined(MHD_USE_DESIG_NEST_INIT)
|
|
|
+/* = MHD Response Option macros below are generated automatically = */
|
|
|
+
|
|
|
+
|
|
|
+/* = MHD Response Option macros above are generated automatically = */
|
|
|
+
|
|
|
/**
|
|
|
- * Additional information about request termination
|
|
|
+ * Terminate the list of the options
|
|
|
+ * @return the terminating object of struct MHD_ResponseOptionAndValue
|
|
|
*/
|
|
|
-union MHD_RequestTerminationDetail
|
|
|
-{
|
|
|
- /**
|
|
|
- * Reserved member.
|
|
|
- * Do not use.
|
|
|
- */
|
|
|
- void *reserved;
|
|
|
-};
|
|
|
+# define MHD_R_OPTION_TERMINATE() \
|
|
|
+ MHD_NOWARN_COMPOUND_LITERALS_ \
|
|
|
+ (const struct MHD_DaemonOptionAndValue) \
|
|
|
+ { \
|
|
|
+ .opt = (MHD_R_O_END) \
|
|
|
+ } \
|
|
|
+ MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
|
|
|
|
|
+#else /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */
|
|
|
+MHD_NOWARN_UNUSED_FUNC_
|
|
|
+/* = MHD Response Option static functions below are generated automatically = */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/* = MHD Response Option static functions above are generated automatically = */
|
|
|
/**
|
|
|
- * Request termination data structure
|
|
|
+ * Terminate the list of the options
|
|
|
+ * @return the terminating object of struct MHD_ResponseOptionAndValue
|
|
|
*/
|
|
|
-struct MHD_RequestTerminationData
|
|
|
+static MHD_INLINE struct MHD_DaemonOptionAndValue
|
|
|
+MHD_R_OPTION_TERMINATE (void)
|
|
|
{
|
|
|
- /**
|
|
|
- * The code of the event
|
|
|
- */
|
|
|
- enum MHD_RequestTerminationCode code;
|
|
|
- /**
|
|
|
- * Detailed information about termination event
|
|
|
- */
|
|
|
- union MHD_RequestTerminationDetail details;
|
|
|
-};
|
|
|
+ struct MHD_DaemonOptionAndValue opt_val;
|
|
|
+
|
|
|
+ opt_val.opt = MHD_R_O_END;
|
|
|
+
|
|
|
+ return opt_val;
|
|
|
+}
|
|
|
+
|
|
|
+MHD_RESTORE_WARN_UNUSED_FUNC_
|
|
|
+#endif /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * Signature of the callback used by MHD to notify the application
|
|
|
- * about completed requests.
|
|
|
+ * Set the requested options for the response.
|
|
|
*
|
|
|
- * @param cls client-defined closure
|
|
|
- * @param data the details about the event
|
|
|
- * @param request_context request context value, as originally
|
|
|
- * returned by the #MHD_EarlyUriLogCallback
|
|
|
- * @see #MHD_option_request_completion()
|
|
|
- * @ingroup request
|
|
|
+ * If any option fail other options may be or may be not applied.
|
|
|
+ * @param response the response to set the options
|
|
|
+ * @param[in] options the pointer to the array with the options;
|
|
|
+ * the array processing stops at the first ::MHD_D_O_END
|
|
|
+ * option, but not later than after processing
|
|
|
+ * @a options_max_num entries
|
|
|
+ * @param options_max_num the maximum number of entries in the @a options,
|
|
|
+ * use #MHD_OPTIONS_ARRAY_MAX_SIZE if options processing
|
|
|
+ * must stop only at zero-termination option
|
|
|
+ * @return ::MHD_SC_OK on success,
|
|
|
+ * error code otherwise
|
|
|
*/
|
|
|
-typedef void
|
|
|
-(*MHD_RequestTerminationCallback) (void *cls,
|
|
|
- struct MHD_RequestTerminationData *data,
|
|
|
- void *request_context);
|
|
|
+MHD_EXTERN_ enum MHD_StatusCode
|
|
|
+MHD_response_options_set(struct MHD_Response *daemon,
|
|
|
+ const struct MHD_ResponseOptionAndValue *options,
|
|
|
+ size_t options_max_num)
|
|
|
+MHD_FN_PAR_NONNULL_ALL_;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * Set a function to be called once MHD is finished with the
|
|
|
- * request.
|
|
|
+ * Set the requested single option for the response.
|
|
|
*
|
|
|
- * @param[in,out] response which response to set the callback for
|
|
|
- * @param termination_cb function to call, can be NULL to not use the callback
|
|
|
- * @param termination_cb_cls closure for @e termination_cb
|
|
|
+ * @param response the response to set the option
|
|
|
+ * @param[in] options the pointer to the option
|
|
|
+ * @return ::MHD_SC_OK on success,
|
|
|
+ * error code otherwise
|
|
|
*/
|
|
|
-MHD_EXTERN_ enum MHD_StatusCode
|
|
|
-MHD_response_set_option_termination_callback (
|
|
|
- struct MHD_Response *response,
|
|
|
- MHD_RequestTerminationCallback termination_cb,
|
|
|
- void *termination_cb_cls)
|
|
|
-MHD_FN_PAR_NONNULL_ (1);
|
|
|
+#define MHD_response_option_set(response,option_ptr) \
|
|
|
+ MHD_response_options_set(response,options_ptr,1)
|
|
|
+
|
|
|
+
|
|
|
+#ifdef MHD_USE_VARARG_MACROS
|
|
|
+MHD_NOWARN_VARIADIC_MACROS_
|
|
|
+# if defined(MHD_USE_COMPOUND_LITERALS) && \
|
|
|
+ defined(MHD_USE_COMP_LIT_FUNC_PARAMS)
|
|
|
+/**
|
|
|
+ * Set the requested options for the response.
|
|
|
+ *
|
|
|
+ * If any option fail other options may be or may be not applied.
|
|
|
+ *
|
|
|
+ * It should be used with helpers that creates required options, for example:
|
|
|
+ *
|
|
|
+ * MHD_RESPONE_OPTIONS_SET(d, MHD_D_OPTION_SUPPRESS_DATE_HEADER(MHD_YES), // TODO: use correct macros
|
|
|
+ * MHD_D_OPTION_SOCK_ADDR(sa_len, sa))
|
|
|
+ *
|
|
|
+ * @param response the response to set the option
|
|
|
+ * @param ... the list of the options, each option must be created
|
|
|
+ * by helpers MHD_RESPONSE_OPTION_NameOfOption(option_value)
|
|
|
+ * @return ::MHD_SC_OK on success,
|
|
|
+ * error code otherwise
|
|
|
+ */
|
|
|
+# define MHD_RESPONSE_OPTIONS_SET(response,...) \
|
|
|
+ MHD_NOWARN_COMPOUND_LITERALS_ \
|
|
|
+ MHD_response_options_set(daemon, \
|
|
|
+ ((const struct MHD_ResponseOptionAndValue[]) \
|
|
|
+ {__VA_ARGS__, MHD_R_OPTION_TERMINATE()}), \
|
|
|
+ MHD_OPTIONS_ARRAY_MAX_SIZE) \
|
|
|
+ MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
|
|
+# elif defined(MHD_USE_CPP_INIT_LIST)
|
|
|
+} /* extern "C" */
|
|
|
+# include <vector>
|
|
|
+extern "C"
|
|
|
+{
|
|
|
+/**
|
|
|
+ * Set the requested options for the daemon.
|
|
|
+ *
|
|
|
+ * If any option fail other options may be or may be not applied.
|
|
|
+ *
|
|
|
+ * It should be used with helpers that creates required options, for example:
|
|
|
+ *
|
|
|
+ * MHD_DAEMON_OPTIONS_SET(d, MHD_D_OPTION_SUPPRESS_DATE_HEADER(MHD_YES), // TODO: use correct macros
|
|
|
+ * MHD_D_OPTION_SOCK_ADDR(sa_len, sa))
|
|
|
+ *
|
|
|
+ * @param daemon the daemon to set the options
|
|
|
+ * @param ... the list of the options, each option must be created
|
|
|
+ * by helpers MHD_D_OPTION_NameOfOption(option_value)
|
|
|
+ * @return ::MHD_SC_OK on success,
|
|
|
+ * error code otherwise
|
|
|
+ */
|
|
|
+# define MHD_DAEMON_OPTIONS_SET(daemon,...) \
|
|
|
+ MHD_NOWARN_CPP_INIT_LIST_ \
|
|
|
+ MHD_daemon_options_set(daemon, \
|
|
|
+ (std::vector<struct MHD_DaemonOptionAndValue> \
|
|
|
+ {__VA_ARGS__,MHD_R_OPTION_TERMINATE()}).data(), \
|
|
|
+ MHD_OPTIONS_ARRAY_MAX_SIZE) \
|
|
|
+ MHD_RESTORE_WARN_CPP_INIT_LIST_
|
|
|
+# endif
|
|
|
+MHD_RESTORE_WARN_VARIADIC_MACROS_
|
|
|
+#endif /* MHD_USE_VARARG_MACROS && MHD_USE_COMP_LIT_FUNC_PARAMS */
|
|
|
|
|
|
|
|
|
/**
|