/**
   * Remove unwanted headers from the given header map.
   *
   * @param headers Header map
   * @param nHttpConfiguration NHttp transporter base configurations
   */
  private void removeUnwantedHeadersFromHeaderMap(
      Map headers, NHttpConfiguration nHttpConfiguration) {

    Iterator iter = headers.keySet().iterator();
    while (iter.hasNext()) {
      String headerName = (String) iter.next();
      if (HTTP.CONN_DIRECTIVE.equalsIgnoreCase(headerName)
          || HTTP.TRANSFER_ENCODING.equalsIgnoreCase(headerName)
          || HTTP.CONTENT_TYPE.equalsIgnoreCase(headerName)
          || HTTP.CONTENT_LEN.equalsIgnoreCase(headerName)) {
        iter.remove();
      }

      if (HTTP.SERVER_HEADER.equalsIgnoreCase(headerName)
          && !nHttpConfiguration.isPreserveHttpHeader(HTTP.SERVER_HEADER)) {
        iter.remove();
      }

      if (HTTP.USER_AGENT.equalsIgnoreCase(headerName)
          && !nHttpConfiguration.isPreserveHttpHeader(HTTP.USER_AGENT)) {
        iter.remove();
      }

      if (HTTP.DATE_HEADER.equalsIgnoreCase(headerName)
          && !nHttpConfiguration.isPreserveHttpHeader(HTTP.DATE_HEADER)) {
        iter.remove();
      }
    }
  }
 /**
  * Add the given headers to the given HTTP request.
  *
  * @param httpRequest the request to add the headers to
  * @param headers the headers to add
  */
 static void addHeaders(HttpUriRequest httpRequest, HttpHeaders headers) {
   for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
     String headerName = entry.getKey();
     if (HttpHeaders.COOKIE.equalsIgnoreCase(headerName)) { // RFC 6265
       String headerValue = StringUtils.collectionToDelimitedString(entry.getValue(), "; ");
       httpRequest.addHeader(headerName, headerValue);
     } else if (!HTTP.CONTENT_LEN.equalsIgnoreCase(headerName)
         && !HTTP.TRANSFER_ENCODING.equalsIgnoreCase(headerName)) {
       for (String headerValue : entry.getValue()) {
         httpRequest.addHeader(headerName, headerValue);
       }
     }
   }
 }