docstr: Rewrite the ``remote_ip`` and ``protocol`` fields.
code: def _apply_xheaders(self, headers: httputil.HTTPHeaders) -> None:
      """Rewrite the ``remote_ip`` and ``protocol`` fields."""
      # Squid uses X-Forwarded-For, others use X-Real-Ip
      ip = headers.get("X-Forwarded-For", self.remote_ip)
      # Skip trusted downstream hosts in X-Forwarded-For list
      for ip in (cand.strip() for cand in reversed(ip.split(","))):
          if ip not in self.trusted_downstream:
              break
      ip = headers.get("X-Real-Ip", ip)
      if netutil.is_valid_ip(ip):
          self.remote_ip = ip
      # AWS uses X-Forwarded-Proto
      proto_header = headers.get(
          "X-Scheme", headers.get("X-Forwarded-Proto", self.protocol)
      )
      if proto_header:
          # use only the last proto entry if there is more than one
          # TODO: support trusting multiple layers of proxied protocol
          proto_header = proto_header.split(",")[-1].strip()
      if proto_header in ("http", "https"):
          self.protocol = proto_header
  
imports: import socket
  import ssl
  from tornado.escape import native_str
  from tornado.http1connection import HTTP1ServerConnection, HTTP1ConnectionParameters
  from tornado import httputil
  from tornado import iostream
  from tornado import netutil
  from tornado.tcpserver import TCPServer
  from tornado.util import Configurable
  import typing
  from typing import Union, Any, Dict, Callable, List, Type, Tuple, Optional, Awaitable
label_desc: Use image node_id 3 for calling the _HTTPRequestContext obj's underlying member method code with example usage: obj._apply_xheaders(headers) without return types