for (Iterator i = requestHeaders.keySet().iterator(); i.hasNext(); )
for (Iterator i = requestHeaders.iterator(); i.hasNext(); )
  public Response dispatch()    throws IOException  {    if (dispatched)      {        throw new ProtocolException("request already dispatched");      }    final String CRLF = "\r\n";    final String HEADER_SEP = ": ";    final String US_ASCII = "US-ASCII";    final String version = connection.getVersion();    Response response;    int contentLength = -1;    boolean retry = false;    int attempts = 0;    boolean expectingContinue = false;    if (requestBodyWriter != null)      {        contentLength = requestBodyWriter.getContentLength();        String expect = getHeader("Expect");        if (expect != null && expect.equals("100-continue"))          {            expectingContinue = true;          }        else          {            setHeader("Content-Length", Integer.toString(contentLength));          }      }        try      {        // Loop while authentication fails or continue        do          {            retry = false;                        // Get socket output and input streams            OutputStream out = connection.getOutputStream();            // Request line            String requestUri = path;            if (connection.isUsingProxy() &&                !"*".equals(requestUri) &&                !"CONNECT".equals(method))              {                requestUri = getRequestURI();              }            String line = method + ' ' + requestUri + ' ' + version + CRLF;            out.write(line.getBytes(US_ASCII));            // Request headers            for (Iterator i = requestHeaders.keySet().iterator();                 i.hasNext(); )              {                String name =(String) i.next();                String value =(String) requestHeaders.get(name);                line = name + HEADER_SEP + value + CRLF;                out.write(line.getBytes(US_ASCII));              }            out.write(CRLF.getBytes(US_ASCII));            // Request body            if (requestBodyWriter != null && !expectingContinue)              {                byte[] buffer = new byte[4096];                int len;                int count = 0;                                requestBodyWriter.reset();                do                  {                    len = requestBodyWriter.write(buffer);                    if (len > 0)                      {                        out.write(buffer, 0, len);                      }                    count += len;                  }                while (len > -1 && count < contentLength);              }            out.flush();            // Get response            while(true)            {              response = readResponse(connection.getInputStream());            int sc = response.getCode();            if (sc == 401 && authenticator != null)              {                if (authenticate(response, attempts++))                  {                    retry = true;                  }              }              else if (sc == 100)                {                  if (expectingContinue)              {                requestHeaders.remove("Expect");                      setHeader("Content-Length",                                Integer.toString(contentLength));                expectingContinue = false;                retry = true;              }                  else                    {                      // A conforming server can send an unsoliceted                      // Continue response but *should* not (RFC 2616                      // sec 8.2.3).  Ignore the bogus Continue                      // response and get the real response that                      // should follow                      continue;                    }                }              break;            }          }        while (retry);      }    catch (IOException e)      {        connection.close();        throw e;      }    return response;  }