Search in sources :

Example 1 with ContentType

use of org.webpieces.httpparser.api.dto.ContentType in project webpieces by deanhiller.

the class FullResponse method extractCharset.

private Charset extractCharset() {
    Header header = response.getHeaderLookupStruct().getHeader(KnownHeaderName.CONTENT_TYPE);
    if (header == null)
        throw new IllegalArgumentException("no ContentType header could be found");
    ContentType ct = ContentType.parse(header);
    Charset charset = DEFAULT_CHARSET;
    if (ct.getCharSet() != null)
        charset = Charset.forName(ct.getCharSet());
    return charset;
}
Also used : Header(org.webpieces.httpparser.api.common.Header) ContentType(org.webpieces.httpparser.api.dto.ContentType) Charset(java.nio.charset.Charset)

Aggregations

Charset (java.nio.charset.Charset)1 Header (org.webpieces.httpparser.api.common.Header)1 ContentType (org.webpieces.httpparser.api.dto.ContentType)1