Add get_http_request_ip for fetching a requester's IP address.

Review Request #14630 — Created Nov. 28, 2025 and submitted

Information

Djblets
release-5.x

Reviewers

djblets.http.get_http_request_ip returns the IP address stored in the
the X-Real-IP or X-Forwarded-For headers (if available), falling
back to the raw client IP address if needed.

Since this operates off of HTTP headers, it's up to the configured
servers to ensure any client-provided headers are stripped out and that
these are set to trusted values.

Unit tests pass.

Summary ID
Add get_http_request_ip for fetching a requester's IP address.
`djblets.http.get_http_request_ip` returns the IP address stored in the the `X-Real-IP` or `X-Forwarded-For` headers (if available), falling back to the raw client IP address if needed. Since this operates off of HTTP headers, it's up to the configured servers to ensure any client-provided headers are stripped out and that these are set to trusted values.
00059f1d754e74df40b5982ff8ff5a55a2a3fe2e
Description From Last Updated

Please add a module docstring.

daviddavid
david
  1. 
      
  2. djblets/http/tests/test_requests.py (Diff revision 1)
     
     
    Show all issues

    Please add a module docstring.

  3. 
      
chipx86
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.x (a6ccda2)