private String setCharsetFromContentType(String contentType,String charset) {
        String newContentType = "";
        if (contentType == null)
            return (null);
        int start = contentType.indexOf("charset=");
        if (start < 0) {
            //No charset present:
            newContentType = contentType + ";charset=" + charset;
            return newContentType;
        }
        String encoding = contentType.substring(start + 8);
        int end = encoding.indexOf(';');
        if (end >= 0) {
            newContentType = contentType.substring(0,start);
            newContentType = newContentType + "charset=" + charset;
            newContentType = newContentType + encoding.substring(end,encoding.length());
        }
        else {
            newContentType = contentType.substring(0,start);
            newContentType = newContentType + "charset=" + charset;
        }

        return (newContentType.trim());

    }
Can be called multiple times to add Cookies
container-core/src/main/java/com/yahoo/jdisc/http/filter/DiscFilterRequest.java