/** Parses HTTP headers into a {@link BlobMetadata} object. */ private BlobMetadata parseMetadataHeaders(String blobId, EmoResponse response) { // The server always sets X-BV-Length. It's similar to Content-Length but proxies etc. shouldn't mess with it. String lengthString = response.getFirstHeader(X_BV_PREFIX + "Length"); checkState(lengthString != null, "BlobStore request is missing expected required X-BV-Length header."); long length = Long.parseLong(lengthString); // Extract signature hash values. String md5 = base64ToHex(response.getFirstHeader(HttpHeaders.CONTENT_MD5)); String sha1 = stripQuotes(response.getFirstHeader(HttpHeaders.ETAG)); // Extract attribute map specified when the blob was first uploaded. Map<String, String> attributes = Maps.newHashMap(); for (Map.Entry<String, List<String>> entry : response.getHeaders()) { if (entry.getKey().startsWith(X_BVA_PREFIX)) { attributes.put(entry.getKey().substring(X_BVA_PREFIX.length()), entry.getValue().get(0)); } } return new DefaultBlobMetadata(blobId, response.getLastModified(), length, md5, sha1, attributes); }
/** Parses HTTP headers into a {@link BlobMetadata} object. */ private BlobMetadata parseMetadataHeaders(String blobId, EmoResponse response) { // The server always sets X-BV-Length. It's similar to Content-Length but proxies etc. shouldn't mess with it. String lengthString = response.getFirstHeader(X_BV_PREFIX + "Length"); checkState(lengthString != null, "BlobStore request is missing expected required X-BV-Length header."); long length = Long.parseLong(lengthString); // Extract signature hash values. String md5 = base64ToHex(response.getFirstHeader(HttpHeaders.CONTENT_MD5)); String sha1 = stripQuotes(response.getFirstHeader(HttpHeaders.ETAG)); // Extract attribute map specified when the blob was first uploaded. Map<String, String> attributes = Maps.newHashMap(); for (Map.Entry<String, List<String>> entry : response.getHeaders()) { if (entry.getKey().startsWith(X_BVA_PREFIX)) { attributes.put(entry.getKey().substring(X_BVA_PREFIX.length()), entry.getValue().get(0)); } } return new DefaultBlobMetadata(blobId, response.getLastModified(), length, md5, sha1, attributes); }