Source:
private static void addMetadataToResponse(HttpServletRequest request, HttpServletResponse response, BlobMetadata metadata) { ContentMetadata contentMetadata = metadata.getContentMetadata(); addResponseHeaderWithOverride(request, response, HttpHeaders.CACHE_CONTROL, ResponseHeaderOverrides.RESPONSE_HEADER_CACHE_CONTROL, contentMetadata.getCacheControl()); addResponseHeaderWithOverride(request, response, HttpHeaders.CONTENT_ENCODING, ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_ENCODING, contentMetadata.getContentEncoding()); addResponseHeaderWithOverride(request, response, HttpHeaders.CONTENT_LANGUAGE, ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_LANGUAGE, contentMetadata.getContentLanguage()); addResponseHeaderWithOverride(request, response, HttpHeaders.CONTENT_DISPOSITION, ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_DISPOSITION, contentMetadata.getContentDisposition()); response.addHeader(HttpHeaders.CONTENT_LENGTH, contentMetadata.getContentLength().toString()); String overrideContentType = request.getParameter( ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_TYPE); if (overrideContentType != null) { response.setContentType(overrideContentType); } else { response.setContentType(contentMetadata.getContentType()); } HashCode contentMd5 = contentMetadata.getContentMD5AsHashCode(); if (contentMd5 != null) { byte[] contentMd5Bytes = contentMd5.asBytes(); response.addHeader(HttpHeaders.CONTENT_MD5, BaseEncoding.base64().encode(contentMd5Bytes)); response.addHeader(HttpHeaders.ETAG, maybeQuoteETag( BaseEncoding.base16().lowerCase().encode(contentMd5Bytes))); } String overrideExpires = request.getParameter( ResponseHeaderOverrides.RESPONSE_HEADER_EXPIRES); if (overrideExpires != null) { response.addHeader(HttpHeaders.EXPIRES, overrideExpires); } else { Date expires = contentMetadata.getExpires(); if (expires != null) { response.addDateHeader(HttpHeaders.EXPIRES, expires.getTime()); } } response.addDateHeader(HttpHeaders.LAST_MODIFIED, metadata.getLastModified().getTime()); for (Map.Entry<String, String> entry : metadata.getUserMetadata().entrySet()) { response.addHeader(USER_METADATA_PREFIX + entry.getKey(), entry.getValue()); } }

Target:
private static void addMetadataToResponse(HttpServletRequest request, HttpServletResponse response, BlobMetadata metadata) { ContentMetadata contentMetadata = metadata.getContentMetadata(); addResponseHeaderWithOverride(request, response, HttpHeaders.CACHE_CONTROL, "response-cache-control", contentMetadata.getCacheControl()); addResponseHeaderWithOverride(request, response, HttpHeaders.CONTENT_ENCODING, "response-content-encoding", contentMetadata.getContentEncoding()); addResponseHeaderWithOverride(request, response, HttpHeaders.CONTENT_LANGUAGE, "response-content-language", contentMetadata.getContentLanguage()); addResponseHeaderWithOverride(request, response, HttpHeaders.CONTENT_DISPOSITION, "response-content-disposition", contentMetadata.getContentDisposition()); response.addHeader(HttpHeaders.CONTENT_LENGTH, contentMetadata.getContentLength().toString()); String overrideContentType = request.getParameter( "response-content-type"); response.setContentType(overrideContentType != null ? overrideContentType : contentMetadata.getContentType()); HashCode contentMd5 = contentMetadata.getContentMD5AsHashCode(); if (contentMd5 != null) { byte[] contentMd5Bytes = contentMd5.asBytes(); response.addHeader(HttpHeaders.CONTENT_MD5, BaseEncoding.base64().encode(contentMd5Bytes)); response.addHeader(HttpHeaders.ETAG, maybeQuoteETag( BaseEncoding.base16().lowerCase().encode(contentMd5Bytes))); } String overrideExpires = request.getParameter("response-expires"); if (overrideExpires != null) { response.addHeader(HttpHeaders.EXPIRES, overrideExpires); } else { Date expires = contentMetadata.getExpires(); if (expires != null) { response.addDateHeader(HttpHeaders.EXPIRES, expires.getTime()); } } response.addDateHeader(HttpHeaders.LAST_MODIFIED, metadata.getLastModified().getTime()); for (Map.Entry<String, String> entry : metadata.getUserMetadata().entrySet()) { response.addHeader(USER_METADATA_PREFIX + entry.getKey(), entry.getValue()); } }