List of usage examples for org.apache.http.message BasicHeader getElements
public HeaderElement[] getElements() throws ParseException
From source file:org.fcrepo.client.FcrepoResponse.java
/** * Get a map of parameters from the Content-Disposition header if present * /* w w w . ja v a 2s . co m*/ * @return map of Content-Disposition parameters or null */ public Map<String, String> getContentDisposition() { if (contentDisposition == null && headers.containsKey(CONTENT_DISPOSITION)) { final List<String> values = headers.get(CONTENT_DISPOSITION); if (values.isEmpty()) { return null; } contentDisposition = new HashMap<>(); final String value = values.get(0); final BasicHeader header = new BasicHeader(CONTENT_DISPOSITION, value); for (final HeaderElement headEl : header.getElements()) { for (final NameValuePair pair : headEl.getParameters()) { contentDisposition.put(pair.getName(), pair.getValue()); } } } return contentDisposition; }
From source file:com.seal.ui.components.CustomWebView.java
@Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { DownloadItem item = new DownloadItem(url); item.addRequestHeader("Cookie", CookieManager.getInstance().getCookie(url)); String fileName = item.getFileName(); BasicHeader header = new BasicHeader("Content-Disposition", contentDisposition); HeaderElement[] helelms = header.getElements(); if (helelms.length > 0) { HeaderElement helem = helelms[0]; if (helem.getName().equalsIgnoreCase("attachment")) { NameValuePair nmv = helem.getParameterByName("filename"); if (nmv != null) { fileName = nmv.getValue(); }//from w w w . j a va 2 s. co m } } item.setFilename(fileName); item.setIncognito(isPrivateBrowsingEnabled()); DownloadConfirmDialog dialog = new DownloadConfirmDialog(getContext()).setDownloadItem(item) .setCallbackListener(this); dialog.show(); }
From source file:com.acrutiapps.browser.ui.components.CustomWebView.java
@Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { DownloadItem item = new DownloadItem(url); item.addRequestHeader("Cookie", CookieManager.getInstance().getCookie(url)); String fileName = item.getFileName(); BasicHeader header = new BasicHeader("Content-Disposition", contentDisposition); HeaderElement[] helelms = header.getElements(); if (helelms.length > 0) { HeaderElement helem = helelms[0]; if (helem.getName().equalsIgnoreCase("attachment")) { NameValuePair nmv = helem.getParameterByName("filename"); if (nmv != null) { fileName = nmv.getValue(); }/*from ww w .j a v a2 s. co m*/ } } item.setFilename(fileName); item.setIncognito(isPrivateBrowsingEnabled()); DownloadConfirmDialog dialog = new DownloadConfirmDialog(getContext()).setDownloadItem(item) .setCallbackListener(this); dialog.show(); }