nickva commented on code in PR #6063:
URL: https://github.com/apache/couchdb/pull/6063#discussion_r3611937431


##########
src/chttpd/src/chttpd.erl:
##########
@@ -840,6 +841,29 @@ body(#httpd{mochi_req = MochiReq, req_body = ReqBody}) ->
 validate_ctype(Req, Ctype) ->
     couch_httpd:validate_ctype(Req, Ctype).
 
+peer(#httpd{} = Req) ->
+    peer(Req#httpd.mochi_req);
+peer(MochiReq) ->
+    case config:get("chttpd", "peer_header") of
+        undefined ->
+            peer_from_socket(MochiReq);
+        PeerHeader ->
+            case MochiReq:get_header_value(PeerHeader) of
+                undefined ->
+                    peer_from_socket(MochiReq);
+                Peer ->
+                    Peer
+            end
+    end.
+
+peer_from_socket(MochiReq) ->
+    case MochiReq:get(socket) of
+        {remote, _Pid, _} ->
+            nopeer;
+        _ ->
+            MochiReq:get(peer)
+    end.

Review Comment:
   Wonder if we can  remove the duplicate peer/peer_from_socket and just 
export/use the one copy from couch_httpd and instead of having any `nopeer` 
just treat all `atom` keys as `nopeer` and don't lockout of them?



-- 
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]

Reply via email to