/** * Creates a list of {@link AcceptType} objects based on given content type. * @param contentType the content type * @return an immutable one-element list of <code>AcceptType</code> objects that matches only the given content type */ public static List<AcceptType> fromContentType(final ContentType contentType) { return Collections.singletonList(new AcceptType( contentType.getType(), contentType.getSubtype(), contentType.getParameters(), 1F)); }
return true; if (!subtype.equalsIgnoreCase(contentType.getSubtype())) { return false;
return true; if (!subtype.equalsIgnoreCase(contentType.getSubtype())) { return false;
/** * Creates a list of {@link AcceptType} objects based on given content type. * @param contentType the content type * @return an immutable one-element list of <code>AcceptType</code> objects that matches only the given content type */ public static List<AcceptType> fromContentType(final ContentType contentType) { return Collections.singletonList(new AcceptType( contentType.getType(), contentType.getSubtype(), contentType.getParameters(), 1F)); }
private Charset getCharset(final BatchQueryOperation operation) { final ContentType contentType = ContentType.parse(operation.getHeaders().getHeader(HttpHeader.CONTENT_TYPE)); if (contentType != null) { final String charsetValue = contentType.getParameter(ContentType.PARAMETER_CHARSET); if (charsetValue == null) { if (contentType.isCompatible(ContentType.APPLICATION_JSON) || contentType.getSubtype().contains("xml")) { return Charset.forName("UTF-8"); } } else { return Charset.forName(charsetValue); } } return Charset.forName("ISO-8859-1"); }
private Charset getCharset(final BatchQueryOperation operation) { final ContentType contentType = ContentType.parse(operation.getHeaders().getHeader(HttpHeader.CONTENT_TYPE)); if (contentType != null) { final String charsetValue = contentType.getParameter(ContentType.PARAMETER_CHARSET); if (charsetValue == null) { if (contentType.isCompatible(ContentType.APPLICATION_JSON) || contentType.getSubtype().contains("xml")) { return Charset.forName("UTF-8"); } } else { return Charset.forName(charsetValue); } } return Charset.forName("ISO-8859-1"); }
private void updateCurrentCharset(final String currentLine) { if (currentLine != null) { if (currentLine.startsWith(HttpHeader.CONTENT_TYPE)) { final ContentType contentType = ContentType.parse( currentLine.substring(HttpHeader.CONTENT_TYPE.length() + 1, currentLine.length() - 2).trim()); if (contentType != null) { final String charsetString = contentType.getParameter(ContentType.PARAMETER_CHARSET); currentCharset = charsetString == null ? contentType.isCompatible(ContentType.APPLICATION_JSON) || contentType.getSubtype().contains("xml") ? Charset.forName("UTF-8") : DEFAULT_CHARSET : Charset.forName(charsetString); final String boundary = contentType.getParameter(BOUNDARY); if (boundary != null) { currentBoundary = DOUBLE_DASH + boundary; } } } else if (CRLF.equals(currentLine)) { readState.foundLinebreak(); } else if (isBoundary(currentLine)) { readState.foundBoundary(); } } }
private void updateCurrentCharset(final String currentLine) { if (currentLine != null) { if (currentLine.startsWith(HttpHeader.CONTENT_TYPE)) { final ContentType contentType = ContentType.parse( currentLine.substring(HttpHeader.CONTENT_TYPE.length() + 1, currentLine.length() - 2).trim()); if (contentType != null) { final String charsetString = contentType.getParameter(ContentType.PARAMETER_CHARSET); currentCharset = charsetString == null ? contentType.isCompatible(ContentType.APPLICATION_JSON) || contentType.getSubtype().contains("xml") ? Charset.forName("UTF-8") : DEFAULT_CHARSET : Charset.forName(charsetString); final String boundary = contentType.getParameter(BOUNDARY); if (boundary != null) { currentBoundary = DOUBLE_DASH + boundary; } } } else if (CRLF.equals(currentLine)) { readState.foundLinebreak(); } else if (isBoundary(currentLine)) { readState.foundBoundary(); } } }