code: @SuppressWarnings({ "rawtypes", "unchecked", "null" })
      public static Header[] parseHeaders(InputStream is, String charset) throws IOException, HttpException {
          ArrayList headers = new ArrayList();
          String name = null;
          StringBuffer value = null;
          for (;;) {
              String line = HttpParser.readLine(is, charset);
              if ((line == null) || (line.trim().length() < 1)) {
                  break;
              }
  
              // Parse the header name and value
              // Check for folded headers first
              // Detect LWS-char see HTTP/1.0 or HTTP/1.1 Section 2.2
              // discussion on folded headers
              if ((line.charAt(0) == ' ') || (line.charAt(0) == '\t')) {
                  // we have continuation folded header
                  // so append value
                  if (value != null) {
                      value.append(' ');
                      value.append(line.trim());
                  }
              } else {
                  // make sure we save the previous name,value pair if present
                  if (name != null) {
                      headers.add(new Header(name, value.toString()));
                  }
  
                  // Otherwise we should have normal HTTP header line
                  // Parse the header name and value
                  int colon = line.indexOf(":");
                  if (colon < 0) {
                      // Do not thrown the exception ignore it instead
                      // throw new ProtocolException("Unable to parse header: " + line);
                      logger.warn("Ignoring malformed HTTP header line: \"" + line + "\"");
                      name = null;
                      value = null;
                  } else {
                      name = line.substring(0, colon).trim();
                      value = new StringBuffer(line.substring(colon + 1).trim());
                  }
              }
  
          }
  
          // make sure we save the last name,value pair if present
          if (name != null) {
              headers.add(new Header(name, value.toString()));
          }
  
          return (Header[]) headers.toArray(new Header[headers.size()]);
      }
docs: /*
  Implementation copied from HttpParser#parseHeaders(InputStream, String) except that no exception is thrown in case of
  malformed HTTP header lines.