Home / Class/ OcspHttpHandler Class — netty Architecture

OcspHttpHandler Class — netty Architecture

Architecture documentation for the OcspHttpHandler class in OcspHttpHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  cba3eeb4_dd5c_095e_3acf_4cabb8ff9203["OcspHttpHandler"]
  c62a8535_1054_7eb8_9879_7a6b8a0cf3a0["OcspHttpHandler.java"]
  cba3eeb4_dd5c_095e_3acf_4cabb8ff9203 -->|defined in| c62a8535_1054_7eb8_9879_7a6b8a0cf3a0
  2a065433_1d38_29a3_7206_624fab8d3c50["OcspHttpHandler()"]
  cba3eeb4_dd5c_095e_3acf_4cabb8ff9203 -->|method| 2a065433_1d38_29a3_7206_624fab8d3c50
  3a0bac3d_54dc_6e79_a5a2_b982cfbdf22e["channelRead0()"]
  cba3eeb4_dd5c_095e_3acf_4cabb8ff9203 -->|method| 3a0bac3d_54dc_6e79_a5a2_b982cfbdf22e
  ebe35253_b028_67db_a72d_3ed071dd9c51["exceptionCaught()"]
  cba3eeb4_dd5c_095e_3acf_4cabb8ff9203 -->|method| ebe35253_b028_67db_a72d_3ed071dd9c51

Relationship Graph

Source Code

handler-ssl-ocsp/src/main/java/io/netty/handler/ssl/ocsp/OcspHttpHandler.java lines 32–86

final class OcspHttpHandler extends SimpleChannelInboundHandler<FullHttpResponse> {

    private static final InternalLogger LOGGER = InternalLoggerFactory.getInstance(OcspHttpHandler.class);
    private final Promise<OCSPResp> responseFuture;

    static final String OCSP_REQUEST_TYPE = "application/ocsp-request";
    static final String OCSP_RESPONSE_TYPE = "application/ocsp-response";

    /**
     * Create new {@link OcspHttpHandler} instance
     *
     * @param responsePromise {@link Promise} of {@link OCSPResp}
     */
    OcspHttpHandler(Promise<OCSPResp> responsePromise) {
        super(FullHttpResponse.class);
        this.responseFuture = checkNotNull(responsePromise, "ResponsePromise");
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse response) throws Exception {
        try {
            // If DEBUG is enabled then log the response
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Received OCSP HTTP Response: {}", response);
            }

            // Response headers must contain 'Content-Type'
            String contentType = response.headers().get(HttpHeaderNames.CONTENT_TYPE);
            if (contentType == null) {
                throw new OCSPException("HTTP Response does not contain 'CONTENT-TYPE' header");
            }

            // Response headers must contain 'application/ocsp-response'
            if (!contentType.equalsIgnoreCase(OCSP_RESPONSE_TYPE)) {
                throw new OCSPException("Response Content-Type was: " + contentType +
                        "; Expected: " + OCSP_RESPONSE_TYPE);
            }

            // Status must be OK for successful lookup
            if (response.status() != OK) {
                throw new IllegalArgumentException("HTTP Response Code was: " + response.status().code() +
                        "; Expected: 200");
            }

            responseFuture.trySuccess(new OCSPResp(ByteBufUtil.getBytes(response.content())));
        } finally {
            ctx.channel().close();
        }
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        responseFuture.tryFailure(cause);
    }
}

Frequently Asked Questions

What is the OcspHttpHandler class?
OcspHttpHandler is a class in the netty codebase, defined in handler-ssl-ocsp/src/main/java/io/netty/handler/ssl/ocsp/OcspHttpHandler.java.
Where is OcspHttpHandler defined?
OcspHttpHandler is defined in handler-ssl-ocsp/src/main/java/io/netty/handler/ssl/ocsp/OcspHttpHandler.java at line 32.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free