*) Bugfix for UnsupportedEncodingException if the media type contains multiple parameters

See: http://www.yacy-forum.de/viewtopic.php?p=25832#25826

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2654 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 18 years ago
parent 4922ab8920
commit 1aa07a52cd

@ -437,14 +437,18 @@ public final class httpHeader extends TreeMap implements Map {
return extractCharsetFromMimetyeHeader(mimeType);
}
public static String extractCharsetFromMimetyeHeader(String mimeType) {
int idx = mimeType.indexOf(";");
if (idx == -1) return null;
public static String extractCharsetFromMimetyeHeader(String mimeType) {
if (mimeType == null) return null;
String encoding = mimeType.substring(idx + 1).trim();
if (!encoding.startsWith("charset=")) return null;
String[] parts = mimeType.split(";");
if (parts == null || parts.length <= 1) return null;
return encoding.substring("charset=".length()).trim();
for (int i=1; i < parts.length; i++) {
String param = parts[i].trim();
if (param.startsWith("charset=")) return param.substring("charset=".length()).trim();
}
return null;
}
public Date date() {

Loading…
Cancel
Save