List of usage examples for org.apache.http.client.methods CloseableHttpResponse getAllHeaders
Header[] getAllHeaders();
From source file:synapticloop.b2.response.B2DownloadFileResponse.java
/** * Instantiate a bucket response with the JSON response as a string from * the API call. This response is then parsed into the relevant fields. * /*w ww.ja v a 2s. com*/ * @param response The HTTP response object * * @throws B2ApiException if there was an error parsing the response * @throws IOException if there was an error communicating with the API service */ public B2DownloadFileResponse(CloseableHttpResponse response) throws B2ApiException, IOException { if (null != response.getEntity()) { stream = new HttpMethodReleaseInputStream(response); } else { // HEAD responses do not have an entity stream = new NullInputStream(0L); EntityUtils.consume(response.getEntity()); } contentLength = Long.parseLong(response.getFirstHeader(HttpHeaders.CONTENT_LENGTH).getValue()); contentType = response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue(); contentSha1 = response.getFirstHeader(B2ResponseHeaders.HEADER_X_BZ_CONTENT_SHA1).getValue(); fileId = response.getFirstHeader(B2ResponseHeaders.HEADER_X_BZ_FILE_ID).getValue(); fileName = response.getFirstHeader(B2ResponseHeaders.HEADER_X_BZ_FILE_NAME).getValue(); uploadTimestamp = response.getFirstHeader(B2ResponseHeaders.HEADER_X_BZ_UPLOAD_TIMESTAMP).getValue(); for (Header header : response.getAllHeaders()) { String headerName = header.getName(); String headerValue = header.getValue(); String headerNameLowerCase = headerName.toLowerCase(Locale.ENGLISH); if (headerNameLowerCase .startsWith(B2ResponseHeaders.HEADER_X_BZ_INFO_PREFIX.toLowerCase(Locale.ENGLISH))) { fileInfo.put(headerName.substring(B2ResponseHeaders.HEADER_X_BZ_INFO_PREFIX.length()), headerValue); } else { if (!ignoredHeaders.contains(headerNameLowerCase)) { LOGGER.warn("Found a header named '{}' with value '{}', that was not mapped", headerName, headerValue); } } } }