* @throws NumberFormatException
* @see HeaderUtils#copyResponseTransportHeaders(Series, Response)
*/
public static Representation extractEntityHeaders(Iterable<Header> headers,
Representation representation) throws NumberFormatException {
Representation result = (representation == null) ? new EmptyRepresentation()
: representation;
boolean entityHeaderFound = false;
if (headers != null) {
for (Header header : headers) {
if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_CONTENT_TYPE)) {
ContentType contentType = new ContentType(header.getValue());
result.setMediaType(contentType.getMediaType());
if ((result.getCharacterSet() == null)
|| (contentType.getCharacterSet() != null)) {
result.setCharacterSet(contentType.getCharacterSet());
}
entityHeaderFound = true;
} else if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_CONTENT_LENGTH)) {
entityHeaderFound = true;
} else if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_EXPIRES)) {
result.setExpirationDate(HeaderReader.readDate(
header.getValue(), false));
entityHeaderFound = true;
} else if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_CONTENT_ENCODING)) {
new EncodingReader(header.getValue()).addValues(result
.getEncodings());
entityHeaderFound = true;
} else if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_CONTENT_LANGUAGE)) {
new LanguageReader(header.getValue()).addValues(result
.getLanguages());
entityHeaderFound = true;
} else if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_LAST_MODIFIED)) {
result.setModificationDate(HeaderReader.readDate(
header.getValue(), false));
entityHeaderFound = true;
} else if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_ETAG)) {
result.setTag(Tag.parse(header.getValue()));
entityHeaderFound = true;
} else if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_CONTENT_LOCATION)) {
result.setLocationRef(header.getValue());
entityHeaderFound = true;
} else if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_CONTENT_DISPOSITION)) {
try {
result.setDisposition(new DispositionReader(header
.getValue()).readValue());
entityHeaderFound = true;
} catch (IOException ioe) {
Context.getCurrentLogger().log(
Level.WARNING,