commit eb10702659af7a11679422633d8baa4f4a18594e
parent 32c37e1eaf4173c7df28017e8b9ff2177e1aaaab
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Mon, 6 Jul 2026 15:09:47 +0200
Compacted MHD_action_digest_auth_challenge_{p,a} public macros
Diffstat:
2 files changed, 216 insertions(+), 220 deletions(-)
diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h
@@ -8434,135 +8434,133 @@ MHD_STATIC_INLINE_END_
/**
* Create action to reply with Digest Authentication "challenge".
*
- * The @a response must have #MHD_HTTP_STATUS_UNAUTHORIZED status code.
- *
- * If the @a response object cannot be extended with the "challenge",
- * the @a response is used to reply without the "challenge".
- *
- * @param request the request to create the action for
- * @param realm the realm presented to the client
- * @param opaque the string for opaque value, can be NULL, but NULL is
- * not recommended for better compatibility with clients;
- * the recommended format is hex or Base64 encoded string
- * @param domain the optional space-separated list of URIs for which the
- * same authorisation could be used, URIs can be in form
- * "path-absolute" (the path for the same host with initial slash)
- * or in form "absolute-URI" (the full path with protocol), in
- * any case client may assume that URI is in the same "protection
- * space" if it starts with any of values specified here;
- * could be NULL (clients typically assume that the same
- * credentials could be used for any URI on the same host);
- * this list provides information for the client only and does
- * not actually restrict anything on the server side
- * @param indicate_stale if set to #MHD_YES then indication of stale nonce used
- * in the client's request is indicated by adding
- * 'stale=true' to the authentication header, this
- * instructs the client to retry immediately with the new
- * nonce and the same credentials, without asking user
- * for the new password
- * @param mqop the QOP to use
- * @param algo digest algorithm to use; if several algorithms are allowed
- * then one challenge for each allowed algorithm is added
- * @param userhash_support if set to #MHD_YES then support of userhash is
- * indicated, allowing client to provide
- * hash("username:realm") instead of the username in
- * clear text;
- * note that clients are allowed to provide the username
- * in cleartext even if this parameter set to non-zero;
- * when userhash is used, application must be ready to
- * identify users by provided userhash value instead of
- * username; see #MHD_digest_auth_calc_userhash() and
- * #MHD_digest_auth_calc_userhash_hex()
- * @param prefer_utf8 if not set to #MHD_NO, parameter 'charset=UTF-8' is
- * added, indicating for the client that UTF-8 encoding for
- * the username is preferred
- * @param response the response to update; should contain the "access denied"
- * body;
- * note: this function sets the "WWW Authenticate" header and
- * the caller should not set this header;
- * the response must have #MHD_HTTP_STATUS_UNAUTHORIZED status
- * code;
- * the NULL is tolerated (the result is
- * #MHD_SC_RESP_POINTER_NULL)
+ * The @a r response must have #MHD_HTTP_STATUS_UNAUTHORIZED status code.
+ *
+ * If the @a r response object cannot be extended with the "challenge",
+ * the @a r response is used to reply without the "challenge".
+ *
+ * @param rq the request to create the action for
+ * @param l the realm presented to the client
+ * @param o the string for opaque value, can be NULL, but NULL is
+ * not recommended for better compatibility with clients;
+ * the recommended format is hex or Base64 encoded string
+ * @param d the optional space-separated list of URIs for which the
+ * same authorisation could be used, URIs can be in form
+ * "path-absolute" (the path for the same host with initial slash)
+ * or in form "absolute-URI" (the full path with protocol), in
+ * any case client may assume that URI is in the same "protection
+ * space" if it starts with any of values specified here;
+ * could be NULL (clients typically assume that the same
+ * credentials could be used for any URI on the same host);
+ * this list provides information for the client only and does
+ * not actually restrict anything on the server side
+ * @param s if set to #MHD_YES then indication of stale nonce used
+ * in the client's request is indicated by adding
+ * 'stale=true' to the authentication header, this
+ * instructs the client to retry immediately with the new
+ * nonce and the same credentials, without asking user
+ * for the new password
+ * @param q the QOP to use
+ * @param a digest algorithm to use; if several algorithms are allowed
+ * then one challenge for each allowed algorithm is added
+ * @param h if set to #MHD_YES then support of userhash is
+ * indicated, allowing client to provide
+ * hash("username:realm") instead of the username in
+ * clear text;
+ * note that clients are allowed to provide the username
+ * in cleartext even if this parameter set to non-zero;
+ * when userhash is used, application must be ready to
+ * identify users by provided userhash value instead of
+ * username; see #MHD_digest_auth_calc_userhash() and
+ * #MHD_digest_auth_calc_userhash_hex()
+ * @param u if not set to #MHD_NO, parameter 'charset=UTF-8' is
+ * added, indicating for the client that UTF-8 encoding for
+ * the username is preferred
+ * @param r the response to update; should contain the "access denied"
+ * body;
+ * note: this function sets the "WWW Authenticate" header and
+ * the caller should not set this header;
+ * the response must have #MHD_HTTP_STATUS_UNAUTHORIZED status
+ * code;
+ * the NULL is tolerated (the result is
+ * #MHD_SC_RESP_POINTER_NULL)
* @return pointer to the action, the action must be consumed
* otherwise response object may leak;
* NULL if failed or if any action has been already created for
- * the @a request;
+ * the @a rq request;
* when failed the response object is consumed and need not
* to be "destroyed"
* @ingroup authentication
*/
-#define MHD_action_digest_auth_challenge_p(rq,rlm,opq,dmn,stl,mqop,malgo, \
- uh,utf,resp) \
- MHD_action_digest_auth_challenge ((rq),(rlm),(opq),(dmn),(stl),(mqop), \
- (malgo),(uh),(utf),(resp),MHD_NO)
+#define MHD_action_digest_auth_challenge_p(rq, l, o, d, s, q, a, h, u, r) \
+ MHD_action_digest_auth_challenge ((rq),(l),(o),(d),(s),(q), \
+ (a),(h),(u),(r),MHD_NO)
/**
* Create action to reply with Digest Authentication "challenge".
*
- * The @a response must have #MHD_HTTP_STATUS_UNAUTHORIZED status code.
- *
- * If the @a response object cannot be extended with the "challenge",
- * the @a response is aborted.
- *
- * @param request the request to create the action for
- * @param realm the realm presented to the client
- * @param opaque the string for opaque value, can be NULL, but NULL is
- * not recommended for better compatibility with clients;
- * the recommended format is hex or Base64 encoded string
- * @param domain the optional space-separated list of URIs for which the
- * same authorisation could be used, URIs can be in form
- * "path-absolute" (the path for the same host with initial slash)
- * or in form "absolute-URI" (the full path with protocol), in
- * any case client may assume that URI is in the same "protection
- * space" if it starts with any of values specified here;
- * could be NULL (clients typically assume that the same
- * credentials could be used for any URI on the same host);
- * this list provides information for the client only and does
- * not actually restrict anything on the server side
- * @param indicate_stale if set to #MHD_YES then indication of stale nonce used
- * in the client's request is indicated by adding
- * 'stale=true' to the authentication header, this
- * instructs the client to retry immediately with the new
- * nonce and the same credentials, without asking user
- * for the new password
- * @param mqop the QOP to use
- * @param algo digest algorithm to use; if several algorithms are allowed
- * then one challenge for each allowed algorithm is added
- * @param userhash_support if set to #MHD_YES then support of userhash is
- * indicated, allowing client to provide
- * hash("username:realm") instead of the username in
- * clear text;
- * note that clients are allowed to provide the username
- * in cleartext even if this parameter set to non-zero;
- * when userhash is used, application must be ready to
- * identify users by provided userhash value instead of
- * username; see #MHD_digest_auth_calc_userhash() and
- * #MHD_digest_auth_calc_userhash_hex()
- * @param prefer_utf8 if not set to #MHD_NO, parameter 'charset=UTF-8' is
- * added, indicating for the client that UTF-8 encoding for
- * the username is preferred
- * @param response the response to update; should contain the "access denied"
- * body;
- * note: this function sets the "WWW Authenticate" header and
- * the caller should not set this header;
- * the response must have #MHD_HTTP_STATUS_UNAUTHORIZED status
- * code;
- * the NULL is tolerated (the result is
- * #MHD_SC_RESP_POINTER_NULL)
+ * The @a r response must have #MHD_HTTP_STATUS_UNAUTHORIZED status code.
+ *
+ * If the @a r response object cannot be extended with the "challenge",
+ * the @a r response is aborted.
+ *
+ * @param rq the request to create the action for
+ * @param l the realm presented to the client
+ * @param o the string for opaque value, can be NULL, but NULL is
+ * not recommended for better compatibility with clients;
+ * the recommended format is hex or Base64 encoded string
+ * @param d the optional space-separated list of URIs for which the
+ * same authorisation could be used, URIs can be in form
+ * "path-absolute" (the path for the same host with initial slash)
+ * or in form "absolute-URI" (the full path with protocol), in
+ * any case client may assume that URI is in the same "protection
+ * space" if it starts with any of values specified here;
+ * could be NULL (clients typically assume that the same
+ * credentials could be used for any URI on the same host);
+ * this list provides information for the client only and does
+ * not actually restrict anything on the server side
+ * @param s if set to #MHD_YES then indication of stale nonce used
+ * in the client's request is indicated by adding
+ * 'stale=true' to the authentication header, this
+ * instructs the client to retry immediately with the new
+ * nonce and the same credentials, without asking user
+ * for the new password
+ * @param q the QOP to use
+ * @param a digest algorithm to use; if several algorithms are allowed
+ * then one challenge for each allowed algorithm is added
+ * @param h if set to #MHD_YES then support of userhash is
+ * indicated, allowing client to provide
+ * hash("username:realm") instead of the username in
+ * clear text;
+ * note that clients are allowed to provide the username
+ * in cleartext even if this parameter set to non-zero;
+ * when userhash is used, application must be ready to
+ * identify users by provided userhash value instead of
+ * username; see #MHD_digest_auth_calc_userhash() and
+ * #MHD_digest_auth_calc_userhash_hex()
+ * @param u if not set to #MHD_NO, parameter 'charset=UTF-8' is
+ * added, indicating for the client that UTF-8 encoding for
+ * the username is preferred
+ * @param r the response to update; should contain the "access denied"
+ * body;
+ * note: this function sets the "WWW Authenticate" header and
+ * the caller should not set this header;
+ * the response must have #MHD_HTTP_STATUS_UNAUTHORIZED status
+ * code;
+ * the NULL is tolerated (the result is
+ * #MHD_SC_RESP_POINTER_NULL)
* @return pointer to the action, the action must be consumed
* otherwise response object may leak;
* NULL if failed or if any action has been already created for
- * the @a request;
+ * the @a rq request;
* when failed the response object is consumed and need not
* to be "destroyed"
* @ingroup authentication
*/
-#define MHD_action_digest_auth_challenge_a(rq,rlm,opq,dmn,stl,mqop,malgo, \
- uh,utf,resp) \
- MHD_action_digest_auth_challenge ((rq),(rlm),(opq),(dmn),(stl),(mqop), \
- (malgo),(uh),(utf),(resp),MHD_YES)
+#define MHD_action_digest_auth_challenge_a(rq, l, o, d, s, q, a, h, u, r) \
+ MHD_action_digest_auth_challenge ((rq),(l),(o),(d),(s),(q), \
+ (a),(h),(u),(r),MHD_YES)
#endif /* ! MHD_NO_STATIC_INLINE */
diff --git a/src/include/microhttpd2_main.h.in b/src/include/microhttpd2_main.h.in
@@ -3516,135 +3516,133 @@ MHD_STATIC_INLINE_END_
/**
* Create action to reply with Digest Authentication "challenge".
*
- * The @a response must have #MHD_HTTP_STATUS_UNAUTHORIZED status code.
- *
- * If the @a response object cannot be extended with the "challenge",
- * the @a response is used to reply without the "challenge".
- *
- * @param request the request to create the action for
- * @param realm the realm presented to the client
- * @param opaque the string for opaque value, can be NULL, but NULL is
- * not recommended for better compatibility with clients;
- * the recommended format is hex or Base64 encoded string
- * @param domain the optional space-separated list of URIs for which the
- * same authorisation could be used, URIs can be in form
- * "path-absolute" (the path for the same host with initial slash)
- * or in form "absolute-URI" (the full path with protocol), in
- * any case client may assume that URI is in the same "protection
- * space" if it starts with any of values specified here;
- * could be NULL (clients typically assume that the same
- * credentials could be used for any URI on the same host);
- * this list provides information for the client only and does
- * not actually restrict anything on the server side
- * @param indicate_stale if set to #MHD_YES then indication of stale nonce used
- * in the client's request is indicated by adding
- * 'stale=true' to the authentication header, this
- * instructs the client to retry immediately with the new
- * nonce and the same credentials, without asking user
- * for the new password
- * @param mqop the QOP to use
- * @param algo digest algorithm to use; if several algorithms are allowed
- * then one challenge for each allowed algorithm is added
- * @param userhash_support if set to #MHD_YES then support of userhash is
- * indicated, allowing client to provide
- * hash("username:realm") instead of the username in
- * clear text;
- * note that clients are allowed to provide the username
- * in cleartext even if this parameter set to non-zero;
- * when userhash is used, application must be ready to
- * identify users by provided userhash value instead of
- * username; see #MHD_digest_auth_calc_userhash() and
- * #MHD_digest_auth_calc_userhash_hex()
- * @param prefer_utf8 if not set to #MHD_NO, parameter 'charset=UTF-8' is
- * added, indicating for the client that UTF-8 encoding for
- * the username is preferred
- * @param response the response to update; should contain the "access denied"
- * body;
- * note: this function sets the "WWW Authenticate" header and
- * the caller should not set this header;
- * the response must have #MHD_HTTP_STATUS_UNAUTHORIZED status
- * code;
- * the NULL is tolerated (the result is
- * #MHD_SC_RESP_POINTER_NULL)
+ * The @a r response must have #MHD_HTTP_STATUS_UNAUTHORIZED status code.
+ *
+ * If the @a r response object cannot be extended with the "challenge",
+ * the @a r response is used to reply without the "challenge".
+ *
+ * @param rq the request to create the action for
+ * @param l the realm presented to the client
+ * @param o the string for opaque value, can be NULL, but NULL is
+ * not recommended for better compatibility with clients;
+ * the recommended format is hex or Base64 encoded string
+ * @param d the optional space-separated list of URIs for which the
+ * same authorisation could be used, URIs can be in form
+ * "path-absolute" (the path for the same host with initial slash)
+ * or in form "absolute-URI" (the full path with protocol), in
+ * any case client may assume that URI is in the same "protection
+ * space" if it starts with any of values specified here;
+ * could be NULL (clients typically assume that the same
+ * credentials could be used for any URI on the same host);
+ * this list provides information for the client only and does
+ * not actually restrict anything on the server side
+ * @param s if set to #MHD_YES then indication of stale nonce used
+ * in the client's request is indicated by adding
+ * 'stale=true' to the authentication header, this
+ * instructs the client to retry immediately with the new
+ * nonce and the same credentials, without asking user
+ * for the new password
+ * @param q the QOP to use
+ * @param a digest algorithm to use; if several algorithms are allowed
+ * then one challenge for each allowed algorithm is added
+ * @param h if set to #MHD_YES then support of userhash is
+ * indicated, allowing client to provide
+ * hash("username:realm") instead of the username in
+ * clear text;
+ * note that clients are allowed to provide the username
+ * in cleartext even if this parameter set to non-zero;
+ * when userhash is used, application must be ready to
+ * identify users by provided userhash value instead of
+ * username; see #MHD_digest_auth_calc_userhash() and
+ * #MHD_digest_auth_calc_userhash_hex()
+ * @param u if not set to #MHD_NO, parameter 'charset=UTF-8' is
+ * added, indicating for the client that UTF-8 encoding for
+ * the username is preferred
+ * @param r the response to update; should contain the "access denied"
+ * body;
+ * note: this function sets the "WWW Authenticate" header and
+ * the caller should not set this header;
+ * the response must have #MHD_HTTP_STATUS_UNAUTHORIZED status
+ * code;
+ * the NULL is tolerated (the result is
+ * #MHD_SC_RESP_POINTER_NULL)
* @return pointer to the action, the action must be consumed
* otherwise response object may leak;
* NULL if failed or if any action has been already created for
- * the @a request;
+ * the @a rq request;
* when failed the response object is consumed and need not
* to be "destroyed"
* @ingroup authentication
*/
-#define MHD_action_digest_auth_challenge_p(rq,rlm,opq,dmn,stl,mqop,malgo, \
- uh,utf,resp) \
- MHD_action_digest_auth_challenge ((rq),(rlm),(opq),(dmn),(stl),(mqop), \
- (malgo),(uh),(utf),(resp),MHD_NO)
+#define MHD_action_digest_auth_challenge_p(rq, l, o, d, s, q, a, h, u, r) \
+ MHD_action_digest_auth_challenge ((rq),(l),(o),(d),(s),(q), \
+ (a),(h),(u),(r),MHD_NO)
/**
* Create action to reply with Digest Authentication "challenge".
*
- * The @a response must have #MHD_HTTP_STATUS_UNAUTHORIZED status code.
- *
- * If the @a response object cannot be extended with the "challenge",
- * the @a response is aborted.
- *
- * @param request the request to create the action for
- * @param realm the realm presented to the client
- * @param opaque the string for opaque value, can be NULL, but NULL is
- * not recommended for better compatibility with clients;
- * the recommended format is hex or Base64 encoded string
- * @param domain the optional space-separated list of URIs for which the
- * same authorisation could be used, URIs can be in form
- * "path-absolute" (the path for the same host with initial slash)
- * or in form "absolute-URI" (the full path with protocol), in
- * any case client may assume that URI is in the same "protection
- * space" if it starts with any of values specified here;
- * could be NULL (clients typically assume that the same
- * credentials could be used for any URI on the same host);
- * this list provides information for the client only and does
- * not actually restrict anything on the server side
- * @param indicate_stale if set to #MHD_YES then indication of stale nonce used
- * in the client's request is indicated by adding
- * 'stale=true' to the authentication header, this
- * instructs the client to retry immediately with the new
- * nonce and the same credentials, without asking user
- * for the new password
- * @param mqop the QOP to use
- * @param algo digest algorithm to use; if several algorithms are allowed
- * then one challenge for each allowed algorithm is added
- * @param userhash_support if set to #MHD_YES then support of userhash is
- * indicated, allowing client to provide
- * hash("username:realm") instead of the username in
- * clear text;
- * note that clients are allowed to provide the username
- * in cleartext even if this parameter set to non-zero;
- * when userhash is used, application must be ready to
- * identify users by provided userhash value instead of
- * username; see #MHD_digest_auth_calc_userhash() and
- * #MHD_digest_auth_calc_userhash_hex()
- * @param prefer_utf8 if not set to #MHD_NO, parameter 'charset=UTF-8' is
- * added, indicating for the client that UTF-8 encoding for
- * the username is preferred
- * @param response the response to update; should contain the "access denied"
- * body;
- * note: this function sets the "WWW Authenticate" header and
- * the caller should not set this header;
- * the response must have #MHD_HTTP_STATUS_UNAUTHORIZED status
- * code;
- * the NULL is tolerated (the result is
- * #MHD_SC_RESP_POINTER_NULL)
+ * The @a r response must have #MHD_HTTP_STATUS_UNAUTHORIZED status code.
+ *
+ * If the @a r response object cannot be extended with the "challenge",
+ * the @a r response is aborted.
+ *
+ * @param rq the request to create the action for
+ * @param l the realm presented to the client
+ * @param o the string for opaque value, can be NULL, but NULL is
+ * not recommended for better compatibility with clients;
+ * the recommended format is hex or Base64 encoded string
+ * @param d the optional space-separated list of URIs for which the
+ * same authorisation could be used, URIs can be in form
+ * "path-absolute" (the path for the same host with initial slash)
+ * or in form "absolute-URI" (the full path with protocol), in
+ * any case client may assume that URI is in the same "protection
+ * space" if it starts with any of values specified here;
+ * could be NULL (clients typically assume that the same
+ * credentials could be used for any URI on the same host);
+ * this list provides information for the client only and does
+ * not actually restrict anything on the server side
+ * @param s if set to #MHD_YES then indication of stale nonce used
+ * in the client's request is indicated by adding
+ * 'stale=true' to the authentication header, this
+ * instructs the client to retry immediately with the new
+ * nonce and the same credentials, without asking user
+ * for the new password
+ * @param q the QOP to use
+ * @param a digest algorithm to use; if several algorithms are allowed
+ * then one challenge for each allowed algorithm is added
+ * @param h if set to #MHD_YES then support of userhash is
+ * indicated, allowing client to provide
+ * hash("username:realm") instead of the username in
+ * clear text;
+ * note that clients are allowed to provide the username
+ * in cleartext even if this parameter set to non-zero;
+ * when userhash is used, application must be ready to
+ * identify users by provided userhash value instead of
+ * username; see #MHD_digest_auth_calc_userhash() and
+ * #MHD_digest_auth_calc_userhash_hex()
+ * @param u if not set to #MHD_NO, parameter 'charset=UTF-8' is
+ * added, indicating for the client that UTF-8 encoding for
+ * the username is preferred
+ * @param r the response to update; should contain the "access denied"
+ * body;
+ * note: this function sets the "WWW Authenticate" header and
+ * the caller should not set this header;
+ * the response must have #MHD_HTTP_STATUS_UNAUTHORIZED status
+ * code;
+ * the NULL is tolerated (the result is
+ * #MHD_SC_RESP_POINTER_NULL)
* @return pointer to the action, the action must be consumed
* otherwise response object may leak;
* NULL if failed or if any action has been already created for
- * the @a request;
+ * the @a rq request;
* when failed the response object is consumed and need not
* to be "destroyed"
* @ingroup authentication
*/
-#define MHD_action_digest_auth_challenge_a(rq,rlm,opq,dmn,stl,mqop,malgo, \
- uh,utf,resp) \
- MHD_action_digest_auth_challenge ((rq),(rlm),(opq),(dmn),(stl),(mqop), \
- (malgo),(uh),(utf),(resp),MHD_YES)
+#define MHD_action_digest_auth_challenge_a(rq, l, o, d, s, q, a, h, u, r) \
+ MHD_action_digest_auth_challenge ((rq),(l),(o),(d),(s),(q), \
+ (a),(h),(u),(r),MHD_YES)
#endif /* ! MHD_NO_STATIC_INLINE */