Java Code Examples for com.linecorp.armeria.common.HttpStatus#NOT_MODIFIED

The following examples show how to use com.linecorp.armeria.common.HttpStatus#NOT_MODIFIED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpHealthChecker.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(HttpObject obj) {
    if (closeable.isClosing()) {
        subscription.cancel();
        return;
    }

    try {
        if (!(obj instanceof ResponseHeaders)) {
            ReferenceCountUtil.release(obj);
            return;
        }

        final ResponseHeaders headers = (ResponseHeaders) obj;
        updateLongPollingSettings(headers);

        final HttpStatus status = headers.status();
        final HttpStatusClass statusClass = status.codeClass();
        switch (statusClass) {
            case INFORMATIONAL:
                maybeSchedulePingCheck();
                break;
            case SERVER_ERROR:
                receivedExpectedResponse = true;
                break;
            case SUCCESS:
                isHealthy = true;
                receivedExpectedResponse = true;
                break;
            default:
                if (status == HttpStatus.NOT_MODIFIED) {
                    isHealthy = wasHealthy;
                    receivedExpectedResponse = true;
                } else {
                    // Do not use long polling on an unexpected status for safety.
                    maxLongPollingSeconds = 0;

                    if (statusClass == HttpStatusClass.CLIENT_ERROR) {
                        logger.warn("{} Unexpected 4xx health check response: {} A 4xx response " +
                                    "generally indicates a misconfiguration of the client. " +
                                    "Did you happen to forget to configure the {}'s client options?",
                                    reqCtx, headers, HealthCheckedEndpointGroup.class.getSimpleName());
                    } else {
                        logger.warn("{} Unexpected health check response: {}", reqCtx, headers);
                    }
                }
        }
    } finally {
        subscription.request(1);
    }
}