code: private RESTResponse readResponse() throws IOException {
          // Read response code from the header line.
          HttpCode resultCode = readStatusLine();
          
          // Read and save headers, keeping track of content-length if we find it.
          Map<String, String> headers = new HashMap<String, String>();
          int contentLength = 0;
          String headerLine = readHeader();
          while (headerLine.length() > 2) {
              // Read header and split into parts based on ":" separator. Both parts are
              // trimmed, and the header is up-cased.
              int colonInx = headerLine.indexOf(':');
              String headerName =     // Use the whole line if there's no colon
                  colonInx <= 0 ? headerLine.trim().toUpperCase()
                                : headerLine.substring(0, colonInx).trim().toUpperCase();
              String headerValue =    // Use an empty string if there's no colon
                  colonInx <= 0 ? "" : headerLine.substring(colonInx + 1).trim();
              headers.put(headerName, headerValue);
              if (headerName.equals(HttpDefs.CONTENT_LENGTH)) {
                  try {
                      contentLength = Integer.parseInt(headerValue);
                  } catch (NumberFormatException e) {
                      // Turn into IOException
                      throw new IOException("Invalid content-length value: " + headerLine);
                  }
              }
              headerLine = readHeader();
          }
  
          // Final header line should be CRLF
          if (!headerLine.equals("\r\n")) {
              throw new IOException("Header not properly terminated: " + headerLine);
          }
          
          // If we have a response entity, read that now.
          byte[] body = null;
          if (contentLength > 0) {
              body = readBody(contentLength);
              
              // Decompress output entity if needed.
              String contentEncoding = headers.get(HttpDefs.CONTENT_ENCODING);
              if (contentEncoding != null) {
                  Utils.require(contentEncoding.equalsIgnoreCase("gzip"),
                                "Unrecognized output Content-Encoding: " + contentEncoding);
                  body = Utils.decompressGZIP(body);
              }
          }
          return new RESTResponse(resultCode, body, headers);
      }
docs: a RESTResponse object.