Add get_http_request_ip for fetching a requester's IP address.

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

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.
af98fe0b724bc04dcd0e1e9973242c40240f0fdb
Description From Last Updated

Please add a module docstring.

daviddavid
Checks run (2 succeeded)
flake8 passed.
JSHint passed.
david
  1. 
      
  2. djblets/http/tests/test_requests.py (Diff revision 1)
     
     
    Show all issues

    Please add a module docstring.

  3.