code: public int getResponseCode() throws IOException {
          if (responseCode != -1) {
              return responseCode;
          }
  
          // Make sure we've gotten the headers
          getInputStream();
          String resp = getHeaderField(0);
  
          // should have no leading/trailing LWS
          // expedite the typical case by assuming it has the
          // form "HTTP/1.x <WS> 2XX <mumble>"
          int ind;
  
          try {
              ind = resp.indexOf(' ');
              while (resp.charAt(ind) == ' ') {
                  ind++;
              }
              responseCode = Integer.parseInt(resp.substring(ind, ind + 3));
              responseMessage = resp.substring(ind + 4).trim();
              return responseCode;
          }
          catch (Exception e) {
              return responseCode;
          }
      }
docs: Gets HTTP response status from responses like:
  <PRE>
  HTTP/1.0 200 OK
  HTTP/1.0 401 Unauthorized
  </PRE>
  Extracts the ints 200 and 401 respectively.
  Returns -1 if none can be discerned
  from the response (i.e., the response is not valid HTTP).
  <p/>
  <!-- This is the J2SE 1.3 implementation... -->
  
  @return the HTTP Status-Code
  @throws IOException if an error occurred connecting to the server.