code: private long getChunkSize() throws IOException {
          final int st = this.state;
          switch (st) {
          case CHUNK_CRLF:
              this.buffer.clear();
              final int bytesRead1 = this.in.readLine(this.buffer);
              if (bytesRead1 == -1) {
                  throw new MalformedChunkCodingException(
                      "CRLF expected at end of chunk");
              }
              if (!this.buffer.isEmpty()) {
                  throw new MalformedChunkCodingException(
                      "Unexpected content at the end of chunk");
              }
              state = CHUNK_LEN;
              //$FALL-THROUGH$
          case CHUNK_LEN:
              this.buffer.clear();
              final int bytesRead2 = this.in.readLine(this.buffer);
              if (bytesRead2 == -1) {
                  throw new ConnectionClosedException("Premature end of chunk coded message body: " +
                          "closing chunk expected");
              }
              int separator = this.buffer.indexOf(';');
              if (separator < 0) {
                  separator = this.buffer.length();
              }
              final String s = this.buffer.substringTrimmed(0, separator);
              try {
                  return Long.parseLong(s, 16);
              } catch (final NumberFormatException e) {
                  throw new MalformedChunkCodingException("Bad chunk header: " + s);
              }
          default:
              throw new IllegalStateException("Inconsistent codec state");
          }
      }
docs: Expects the stream to start with a chunksize in hex with optional
  comments after a semicolon. The line must end with a CRLF: "a3; some
  comment\r\n" Positions the stream at the start of the next line.