public long determineLength(HttpMessage httpMessage) throws HttpException {
   Args.notNull(httpMessage, "HTTP message");
   Header firstHeader = httpMessage.getFirstHeader(HTTP.TRANSFER_ENCODING);
   if (firstHeader != null) {
     String value = firstHeader.getValue();
     if (HTTP.CHUNK_CODING.equalsIgnoreCase(value)) {
       if (!httpMessage.getProtocolVersion().lessEquals(HttpVersion.HTTP_1_0)) {
         return -2;
       }
       throw new ProtocolException(
           "Chunked transfer encoding not allowed for " + httpMessage.getProtocolVersion());
     } else if (HTTP.IDENTITY_CODING.equalsIgnoreCase(value)) {
       return -1;
     } else {
       throw new ProtocolException("Unsupported transfer encoding: " + value);
     }
   }
   firstHeader = httpMessage.getFirstHeader(HTTP.CONTENT_LEN);
   if (firstHeader == null) {
     return (long) this.implicitLen;
   }
   String value2 = firstHeader.getValue();
   try {
     long parseLong = Long.parseLong(value2);
     if (parseLong >= 0) {
       return parseLong;
     }
     throw new ProtocolException("Negative content length: " + value2);
   } catch (NumberFormatException e) {
     throw new ProtocolException("Invalid content length: " + value2);
   }
 }