nickva commented on code in PR #5326: URL: https://github.com/apache/couchdb/pull/5326#discussion_r1821385483
########## src/chttpd/src/chttpd.erl: ########## @@ -431,6 +431,34 @@ handle_req_after_auth(HandlerKey, HttpReq) -> {HttpReq, catch_error(HttpReq, ErrorType, Error, Stack)} end. +nonce(MochiReq) -> + case MochiReq:get_header_value("X-Couch-Request-ID") of + undefined -> + new_nonce(); + Value -> + case re:run(Value, nonce_regex(), [{capture, none}]) of + match -> + Value; + nomatch -> + new_nonce() + end + end. + +new_nonce() -> + couch_util:to_hex(crypto:strong_rand_bytes(5)). + +nonce_regex() -> + Key = chttpd_request_id_regex, Review Comment: Usually persistent terms are namespaced with a module they originated from `{?MODULE, ...key...}` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@couchdb.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org