code: protected void addHostRequestHeader(HttpState state, HttpConnection conn)
      throws IOException, HttpException {
          LOG.trace("enter HttpMethodBase.addHostRequestHeader(HttpState, "
                    + "HttpConnection)");
  
          // Per 19.6.1.1 of RFC 2616, it is legal for HTTP/1.0 based
          // applications to send the Host request-header.
          // TODO: Add the ability to disable the sending of this header for
          //       HTTP/1.0 requests.
          String host = this.params.getVirtualHost();
          if (host != null) {
              LOG.debug("Using virtual host name: " + host);
          } else {
              host = conn.getHost();
          }
          int port = conn.getPort();
  
          // Note: RFC 2616 uses the term "internet host name" for what goes on the
          // host line.  It would seem to imply that host should be blank if the
          // host is a number instead of an name.  Based on the behavior of web
          // browsers, and the fact that RFC 2616 never defines the phrase "internet
          // host name", and the bad behavior of HttpClient that follows if we
          // send blank, I interpret this as a small misstatement in the RFC, where
          // they meant to say "internet host".  So IP numbers get sent as host
          // entries too. -- Eric Johnson 12/13/2002
          if (LOG.isDebugEnabled()) {
              LOG.debug("Adding Host request header");
          }
  
          //appends the port only if not using the default port for the protocol
          if (conn.getProtocol().getDefaultPort() != port) {
              host += (":" + port);
          }
  
          setRequestHeader("Host", host);
      }
docs: Generates <tt>Host</tt> request header, as long as no <tt>Host</tt> request
  header already exists.
  
  @param state the {@link HttpState state} information associated with this method
  @param conn the {@link HttpConnection connection} used to execute
  this HTTP method
  
  @throws IOException if an I/O (transport) error occurs. Some transport exceptions
  can be recovered from.
  @throws HttpException  if a protocol exception occurs. Usually protocol exceptions
  cannot be recovered from.