public static CaseInsensitiveMap<String> extractHeaders(HttpResponse response) { final CaseInsensitiveMap<String> headers = new CaseInsensitiveMap<String>(); for (Header header : response.getAllHeaders()) { headers.add(header.getName(), header.getValue()); } return headers; }
private static void saveHeader( final String name, @Nullable final HttpResponse response, final File baseFile) { final Header header = response != null ? response.getFirstHeader(name) : null; final File file = filenameForHeader(baseFile, name); if (header == null) { FileUtils.deleteIgnoringFailure(file); } else { try { saveToFile(new ByteArrayInputStream(header.getValue().getBytes("UTF-8")), file); } catch (final UnsupportedEncodingException e) { // Do not try to display the header in the log message, as our default encoding is // likely to be UTF-8 and it will fail as well. Log.e("LocalStorage.saveHeader: unable to decode header", e); } } }
private String getCreds(String password) { Header authenticate = new BasicAuthHeaderProvider(USERNAME, password).getAuthHeader(null, null, null); return authenticate.getValue(); }