@Override 
    protected Long getContentLength(String s, MediaType contentType) { 
        if (contentType != null && contentType.getCharSet() != null) { 
            Charset charset = contentType.getCharSet(); 
            try { 
                return (long) s.getBytes(charset.name()).length; 
            } catch (UnsupportedEncodingException ex) {                 
                throw new InternalError(ex.getMessage()); 
            } 
        } else { 
            return null; 
        } 
    }