docs: protected void addCookieRequestHeader(HttpState state, HttpConnection conn)
          throws IOException, HttpException {
  
          LOG.trace("enter HttpMethodBase.addCookieRequestHeader(HttpState, "
                    + "HttpConnection)");
  
          Header[] cookieheaders = getRequestHeaderGroup().getHeaders("Cookie");
          for (int i = 0; i < cookieheaders.length; i++) {
              Header cookieheader = cookieheaders[i];
              if (cookieheader.isAutogenerated()) {
                  getRequestHeaderGroup().removeHeader(cookieheader);
              }
          }
  
          CookieSpec matcher = getCookieSpec(state);
          String host = this.params.getVirtualHost();
          if (host == null) {
              host = conn.getHost();
          }
          Cookie[] cookies = matcher.match(host, conn.getPort(),
              getPath(), conn.isSecure(), state.getCookies());
          if ((cookies != null) && (cookies.length > 0)) {
              if (getParams().isParameterTrue(HttpMethodParams.SINGLE_COOKIE_HEADER)) {
                  // In strict mode put all cookies on the same header
                  putAllCookiesInASingleHeader(host, matcher, cookies);
              } else {
                  // In non-strict mode put each cookie on a separate header
                  for (int i = 0; i < cookies.length; i++) {
                      String s = matcher.formatCookie(cookies[i]);
                      getRequestHeaderGroup().addHeader(new Header(HttpHeader.COOKIE, s, true));
                  }
              }
              if (matcher instanceof CookieVersionSupport) {
                  CookieVersionSupport versupport = (CookieVersionSupport) matcher;
                  int ver = versupport.getVersion();
                  boolean needVersionHeader = false;
                  for (int i = 0; i < cookies.length; i++) {
                      if (ver != cookies[i].getVersion()) {
                          needVersionHeader = true;
                      }
                  }
                  if (needVersionHeader) {
                      // Advertise cookie version support
                      getRequestHeaderGroup().addHeader(versupport.getVersionHeader());
                  }
              }
          }
      }