if ("transfer-encoding".equals(nextHeader)) {
if ("chunked".equalsIgnoreCase(nextValue)) {
myTransferEncoding = TransferEncoding.CHUNKED;
} else {
throw new DecodeException("Unknown transfer encoding: " + nextValue);
}
} else if ("content-length".equals(nextHeader)) {
try {
myContentLength = Integer.parseInt(nextValue);
} catch (NumberFormatException e) {
addConformanceProblem("Could not parse Content-Length header value: " + nextHeader);
}
} else if ("content-type".equals(nextHeader)) {
int colonIndex = nextValue.indexOf(';');
if (colonIndex == -1) {
myContentType = nextValue;
} else {
myContentType = nextValue.substring(0, colonIndex);
myEncodingStyle = EncodingStyle.withNameCaseInsensitive(myContentType);
String charsetDef = nextValue.substring(colonIndex + 1).trim();
if (charsetDef.startsWith("charset=")) {
String charsetName = charsetDef.substring(8);
Charset charset;
try {
charset = Charset.forName(charsetName);
} catch (UnsupportedCharsetException e) {
addConformanceProblem("Unsupported or invalid charset: " + charsetName);
continue;
}
setCharset(charset);
}
}
myContentType = myContentType.trim();
} else if ("authorization".equals(nextHeader)) {
int spaceIndex = nextValue.indexOf(' ');
if (spaceIndex == -1) {
throw new DecodeException("Invalid authorization header. No authorization style detected");
}
String type = nextValue.substring(0, spaceIndex);
if ("basic".equalsIgnoreCase(type)) {
String encodedCredentials = nextValue.substring(spaceIndex + 1);
byte[] decodedCredentials = Base64.decodeBase64(encodedCredentials);
String credentialsString = new String(decodedCredentials, getDefaultCharset());
int colonIndex = credentialsString.indexOf(':');
if (colonIndex == -1) {
setUsername(credentialsString);
} else {
setUsername(credentialsString.substring(0, colonIndex));
setPassword(credentialsString.substring(colonIndex + 1));
}
} else {
addConformanceProblem("Invalid authorization type. Only basic authorization is supported.");
}
} else if ("content-coding".equals(nextHeader)) {
if (StringUtils.isNotBlank(nextValue)) {
if ("gzip".equals(nextValue)) {
myGzipCoding = true;
} else {
throw new DecodeException("Unknown content-coding: " + nextValue);
}
}
} else if (HTTP_HEADER_HL7_SIGNATURE_LC.equals(nextHeader)) {
mySignature = nextValue;
}