code: public void copyHeaders(DriverRequest originalRequest, HttpRequest httpRequest) {
          String baseUrl = originalRequest.getBaseUrl().toString();
          String visibleBaseUrl = originalRequest.getVisibleBaseUrl();
          for (Header header : originalRequest.getOriginalRequest().getAllHeaders()) {
              String name = header.getName();
              // Special headers
              if (HttpHeaders.REFERER.equalsIgnoreCase(name) && isForwardedRequestHeader(HttpHeaders.REFERER)) {
                  String value = header.getValue();
                  value = urlRewriter.rewriteReferer(value, baseUrl, visibleBaseUrl);
                  httpRequest.addHeader(name, value);
                  // All other headers are copied if allowed
              } else if (isForwardedRequestHeader(name)) {
                  httpRequest.addHeader(header);
              }
          }
          // process X-Forwarded-For header
          String remoteAddr = originalRequest.getOriginalRequest().getRemoteAddr();
  
          if (remoteAddr != null) {
              String forwardedFor = null;
              if (httpRequest.containsHeader("X-Forwarded-For")) {
                  forwardedFor = httpRequest.getFirstHeader("X-Forwarded-For").getValue();
              }
  
              if (forwardedFor == null) {
                  forwardedFor = remoteAddr;
              } else {
                  forwardedFor = forwardedFor + ", " + remoteAddr;
              }
  
              httpRequest.setHeader("X-Forwarded-For", forwardedFor);
          }
  
          // Process X-Forwarded-Proto header
          if (!httpRequest.containsHeader("X-Forwarded-Proto")) {
              httpRequest.addHeader("X-Forwarded-Proto",
                      UriUtils.extractScheme(originalRequest.getOriginalRequest().getRequestLine().getUri()));
          }
      }
docs: Copy header from originalRequest to httpRequest.
  <p>
  Referer is rewritten. X-Forwarded-* headers are updated.
  
  @param originalRequest
  source request
  @param httpRequest
  destination request