code: def run(self):
      assert not self.proxy_server, (
          "This class is not reentrable. "
          "Please create a new instance."
      )
  
      requests = self.requests
      proxy_thread = self
  
      class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
          timeout = self.timeout
  
          def check_auth(self):
              if proxy_thread.auth is not None:
                  auth_header = self.headers.get("Proxy-Authorization")
                  b64_auth = base64.standard_b64encode(
                      proxy_thread.auth.encode()
                  ).decode()
                  expected_auth = "Basic %s" % b64_auth
                  if auth_header != expected_auth:
                      self.send_response(401)
                      self.send_header("Connection", "close")
                      self.end_headers()
                      self.wfile.write(
                          (
                              "not authenticated. Expected %r, received %r"
                              % (expected_auth, auth_header)
                          ).encode()
                      )
                      self.connection.close()
                      return False
              return True
  
          def do_GET(self):
              if not self.check_auth():
                  return
              requests.append(self.path)
  
              req = urlopen(self.path, timeout=self.timeout)
              self.send_response(req.getcode())
              content_type = req.info().get("content-type", None)
              if content_type:
                  self.send_header("Content-Type", content_type)
              self.send_header("Connection", "close")
              self.end_headers()
              self.copyfile(req, self.wfile)
              self.connection.close()
              req.close()
  
          def do_CONNECT(self):
              if not self.check_auth():
                  return
              requests.append(self.path)
  
              # Make a raw TCP connection to the target server
              host, port = self.path.split(":")
              try:
                  addr = host, int(port)
                  other_connection = socket.create_connection(
                      addr, timeout=self.timeout
                  )
              except OSError:
                  self.send_error(502, "Bad gateway")
                  return
  
              # Respond that a tunnel has been created
              self.send_response(200)
              self.send_header("Connection", "close")
              self.end_headers()
              pipe_sockets(
                  self.connection,  # it closes sockets
                  other_connection,
                  self.timeout,
              )
  
      # ThreadingTCPServer offloads connections to separate threads, so
      # the serve_forever loop doesn't block until connection is closed
      # (unlike TCPServer). This allows to shutdown the serve_forever loop
      # even if there's an open connection.
      try:
          self.proxy_server = SocketServer.ThreadingTCPServer(
              (self.proxy_host, 0), Proxy
          )
  
          # don't hang if there're some open connections
          self.proxy_server.daemon_threads = True
  
          self.proxy_port = self.proxy_server.server_address[1]
      except Exception as e:
          self.socket_created_future.set_exception(e)
          raise
      else:
          self.socket_created_future.set_result(True)
  
      self.proxy_server.serve_forever()
  
imports: import base64
  import http.server
  import select
  import socket
  import socketserver
  import threading
  from urllib.request import urlopen
label_desc: Use image node_id 7 for calling the ProxyServerThread obj's underlying member method code with example usage: obj.run() and returns: True, False