@Override public boolean canEncode(Representation representation) { // EncoderService ignores disabled state if (!isEnabled()) { return false; } return super.canEncode(representation); } }
/** * Allows filtering after its handling by the target Restlet. Does nothing * by default. * * @param request * The request to filter. * @param response * The response to filter. */ @Override public void afterHandle(Request request, Response response) { // Check if encoding of the response entity is needed if (isEncodingResponse() && getEncoderService().canEncode(response.getEntity())) { response.setEntity(encode(request.getClientInfo(), response.getEntity())); } }
/** * Allows filtering before its handling by the target Restlet. Does nothing * by default. * * @param request * The request to filter. * @param response * The response to filter. * @return The continuation status. */ @Override public int beforeHandle(Request request, Response response) { // Check if encoding of the request entity is needed if (isEncodingRequest() && getEncoderService().canEncode(request.getEntity())) { request.setEntity(encode(request.getClientInfo(), request.getEntity())); } return CONTINUE; }