docs: private void connect(final URL pURL, PasswordAuthentication pAuth, String pAuthType, int pRetries) throws IOException {
          // Find correct port
          final int port = (pURL.getPort() > 0)
                  ? pURL.getPort()
                  : HTTP_DEFAULT_PORT;
  
          // Create socket if we don't have one
          if (socket == null) {
              //socket = new Socket(pURL.getHost(), port); // Blocks...
              socket = createSocket(pURL, port, connectTimeout);
              socket.setSoTimeout(timeout);
          }
  
          // Get Socket output stream
          OutputStream os = socket.getOutputStream();
  
          // Connect using HTTP
          writeRequestHeaders(os, pURL, method, requestProperties, usingProxy(), pAuth, pAuthType);
  
          // Get response input stream
          InputStream sis = socket.getInputStream();
          BufferedInputStream is = new BufferedInputStream(sis);
  
          // Detatch reponse headers from reponse input stream
          InputStream header = detatchResponseHeader(is);
  
          // Parse headers and set response code/message
          responseHeaders = parseResponseHeader(header);
          responseHeaderFields = parseHeaderFields(responseHeaders);
  
          //System.err.println("Headers fields:");
          //responseHeaderFields.list(System.err);
          // Test HTTP response code, to see if further action is needed
          switch (getResponseCode()) {
              case HTTP_OK:
                  // 200 OK
                  inputStream = is;
                  errorStream = null;
                  break;
  
                  /*
                    case HTTP_PROXY_AUTH:
                    // 407 Proxy Authentication Required
                    */
              case HTTP_UNAUTHORIZED:
                  // 401 Unauthorized
                  // Set authorization and try again.. Slightly more compatible
                  responseCode = -1;
  
                  // IS THIS REDIRECTION??
                  //if (instanceFollowRedirects) { ???
                  String auth = getHeaderField(HEADER_WWW_AUTH);
  
                  // Missing WWW-Authenticate header for 401 response is an error
                  if (StringUtil.isEmpty(auth)) {
                      throw new ProtocolException("Missing \"" + HEADER_WWW_AUTH + "\" header for response: 401 " + responseMessage);
                  }
  
                  // Get real mehtod from WWW-Authenticate header
                  int SP = auth.indexOf(" ");
                  String method;
                  String realm = null;
  
                  if (SP >= 0) {
                      method = auth.substring(0, SP);
                      if (auth.length() >= SP + 7) {
                          realm = auth.substring(SP + 7);  // " realm=".lenght() == 7
                      }
  
                      // else no realm
                  }
                  else {
                      // Default mehtod is Basic
                      method = SimpleAuthenticator.BASIC;
                  }
  
                  // Get PasswordAuthentication
                  PasswordAuthentication pa = Authenticator.requestPasswordAuthentication(NetUtil.createInetAddressFromURL(pURL), port,
                          pURL.getProtocol(), realm, method);
  
                  // Avoid infinite loop
                  if (pRetries++ <= 0) {
                      throw new ProtocolException("Server redirected too many times (" + maxRedirects + ") (Authentication required: " + auth + ")");  // This is what sun.net.www.protocol.http.HttpURLConnection does
                  }
                  else if (pa != null) {
                      connect(pURL, pa, method, pRetries);
                  }
                  break;
              case HTTP_MOVED_PERM:
                  // 301 Moved Permanently
              case HTTP_MOVED_TEMP:
                  // 302 Found
              case HTTP_SEE_OTHER:
                  // 303 See Other
                  /*
                    case HTTP_USE_PROXY:
                    // 305 Use Proxy
                    // How do we handle this?
                    */
              case HTTP_REDIRECT:
                  // 307 Temporary Redirect
                  //System.err.println("Redirecting " + getResponseCode());
                  if (instanceFollowRedirects) {
                      // Redirect
                      responseCode = -1;                 // Because of the java.net.URLConnection
  
                      // getResponseCode implementation...
                      // ---
                      // I think redirects must be get?
                      //setRequestMethod("GET");
                      // ---
                      String location = getHeaderField("Location");
                      URL newLoc = new URL(pURL, location);
  
                      // Test if we can reuse the Socket
                      if (!(newLoc.getAuthority().equals(pURL.getAuthority()) && (newLoc.getPort() == pURL.getPort()))) {
                          socket.close();                 // Close the socket, won't need it anymore
                          socket = null;
                      }
                      if (location != null) {
                          //System.err.println("Redirecting to " + location);
                          // Avoid infinite loop
                          if (--pRetries <= 0) {
                              throw new ProtocolException("Server redirected too many times (5)");
                          }
                          else {
                              connect(newLoc, pAuth, pAuthType, pRetries);
                          }
                      }
                      break;
                  }
  
                  // ...else, fall through default (if no Location: header)
              default :
                  // Not 200 OK, or any of the redirect responses
                  // Probably an error...
                  errorStream = is;
                  inputStream = null;
          }
  
          // --- Need rethinking...
          // No further questions, let the Socket wait forever (until the server
          // closes the connection)
          //socket.setSoTimeout(0);
          // Probably not... The timeout should only kick if the read BLOCKS.
          // Shutdown output, meaning any writes to the outputstream below will
          // probably fail...
          //socket.shutdownOutput();
          // Not a good idea at all... POSTs need the outputstream to send the
          // form-data.
          // --- /Need rethinking.
          outputStream = os;
      }