Class ResponseCodeEnforcingResponseHandler

  • All Implemented Interfaces:
    org.apache.hc.core5.http.io.HttpClientResponseHandler<Integer>

    public final class ResponseCodeEnforcingResponseHandler
    extends Object
    implements org.apache.hc.core5.http.io.HttpClientResponseHandler<Integer>
    Throws HttpResponseException for all response codes except for the accepted ones. In addition optionally checks for a certain content type and content of the response. Returns the response code if all checks pass.
    • Constructor Detail

      • ResponseCodeEnforcingResponseHandler

        public ResponseCodeEnforcingResponseHandler​(Integer... allowedCodes)
      • ResponseCodeEnforcingResponseHandler

        public ResponseCodeEnforcingResponseHandler​(String expectedContentType,
                                                    Integer... allowedCodes)
      • ResponseCodeEnforcingResponseHandler

        public ResponseCodeEnforcingResponseHandler​(String expectedContentType,
                                                    Predicate<String> responseStringPredicate,
                                                    Integer... allowedCodes)
    • Method Detail

      • handleResponse

        public Integer handleResponse​(org.apache.hc.core5.http.ClassicHttpResponse response)
                               throws org.apache.hc.core5.http.HttpException,
                                      IOException
        Specified by:
        handleResponse in interface org.apache.hc.core5.http.io.HttpClientResponseHandler<Integer>
        Throws:
        org.apache.hc.core5.http.HttpException
        IOException