  constructor(url, options, db, saveTemplate) {
    super(db, saveTemplate);

    // TODO(soon): Support HTTP proxy.
    const safe = ssrfSafeLookup(db, url);

    if (!options) options = {};
    if (!options.headers) options.headers = {};
    options.headers.host = safe.host;
    options.servername = safe.host.split(":")[0];

    if (!saveTemplate) {
      // enable backwards-compatibilty tweaks.
      this.fromHackSession = true;
    }

    const parsedUrl = Url.parse(safe.url);
    this.host = parsedUrl.hostname;
    if (this.fromHackSession) {
      // HackSessionContext.getExternalUiView() apparently ignored any path on the URL. Whoops.
    } else {
      if (parsedUrl.path === "/") {
        // The URL parser says path = "/" for both "http://foo" and "http://foo/". We want to be
        // strict, though.
        this.path = url.endsWith("/") ? "/" : "";
      } else {
        this.path = parsedUrl.path;
      }
    }

    this.port = parsedUrl.port;
    this.protocol = parsedUrl.protocol;
    this.options = options;
  }
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.