public void consumeHeader()

in httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientH2StreamHandler.java [186:225]


    public void consumeHeader(final List<Header> headers, final boolean endStream) throws HttpException, IOException {
        if (done.get()) {
            throw new ProtocolException("Unexpected message headers");
        }
        switch (responseState.get()) {
            case HEADERS:
                final HttpResponse response = DefaultH2ResponseConverter.INSTANCE.convert(headers);
                final int status = response.getCode();
                if (status < HttpStatus.SC_INFORMATIONAL) {
                    throw new ProtocolException("Invalid response: " + new StatusLine(response));
                }
                if (status > HttpStatus.SC_CONTINUE && status < HttpStatus.SC_SUCCESS) {
                    exchangeHandler.consumeInformation(response, context);
                }
                if (requestState.get() == MessageState.ACK) {
                    if (status == HttpStatus.SC_CONTINUE || status >= HttpStatus.SC_SUCCESS) {
                        requestState.set(MessageState.BODY);
                        exchangeHandler.produce(dataChannel);
                    }
                }
                if (status < HttpStatus.SC_SUCCESS) {
                    return;
                }

                final EntityDetails entityDetails = endStream ? null : new IncomingEntityDetails(response, -1);
                context.setResponse(response);
                httpProcessor.process(response, entityDetails, context);
                connMetrics.incrementResponseCount();

                exchangeHandler.consumeResponse(response, entityDetails, context);
                responseState.set(endStream ? MessageState.COMPLETE : MessageState.BODY);
                break;
            case BODY:
                responseState.set(MessageState.COMPLETE);
                exchangeHandler.streamEnd(headers);
                break;
            default:
                throw new ProtocolException("Unexpected message headers");
        }
    }