rnewson commented on code in PR #5326:
URL: https://github.com/apache/couchdb/pull/5326#discussion_r1821394116
##########
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,
+ Regex = config:get("chttpd", "request_id_regex", "^[a-zA-Z0-9-_]{1,64}+$"),
Review Comment:
I can't imagine anyone changing it but I didn't want to hardcode it. good
idea to pre-set it in start_link.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]